aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-03-15 22:13:02 +0100
committerbptato <nincsnevem662@gmail.com>2024-03-15 22:13:02 +0100
commit63337efd3ad3b87bd0a5b42c3617918cb65205b1 (patch)
treeb80583e1714dc3358873e54d40f13ab3f4e867ce
parent6391a9a2abde4e6a681cb0a1a1831d0c1b87026a (diff)
downloadchawan-63337efd3ad3b87bd0a5b42c3617918cb65205b1.tar.gz
data: content type fixes
* do not skip first 5 chars (this is legacy from when we used query strings) * allow practically anything but control chars (so we can use parameters)
-rw-r--r--adapter/protocol/data.nim12
1 files changed, 5 insertions, 7 deletions
diff --git a/adapter/protocol/data.nim b/adapter/protocol/data.nim
index 5f43f9da..e6c7318a 100644
--- a/adapter/protocol/data.nim
+++ b/adapter/protocol/data.nim
@@ -10,14 +10,12 @@ import utils/twtstr
proc main() =
let str = getEnv("MAPPED_URI_PATH")
- const si = "data:".len # start index
const iu = $int(ERROR_INVALID_URL)
- var ct = str.until(',', si)
- for c in ct:
- if c notin AsciiAlphaNumeric and c != '/':
- stdout.write("Cha-Control: ConnectionError " & iu & " invalid data URL")
- return
- let sd = si + ct.len + 1 # data start
+ var ct = str.until(',')
+ if AllChars - Ascii + Controls - {'\t', ' '} in ct:
+ stdout.write("Cha-Control: ConnectionError " & iu & " invalid data URL")
+ return
+ let sd = ct.len + 1 # data start
let body = percentDecode(str, sd)
if ct.endsWith(";base64"):
try: