curl/trurl

Query params values in JSON output have NUL replaced by .

emanuele6 opened this issue · 4 comments

NUL is replaced by . also in the JSON output, not just in the output of -g '{query:}' and -g '{query-all:}'.

Since JSON supports NUL in strings, and values in params are URL decoded, I think it should not be replaced.

 [
   {
     "url": "http://example.org/?q=mr%00smith",
     "parts": {
       "scheme": "http",
       "host": "example.org",
       "path": "/",
       "query": "q=mr%00smith"
     },
     "params": [
       {
         "key": "q",
-        "value": "mr.smith"
+        "value": "mr\u0000smith"
       }
     ]
   }
 ]

Fair point!

When we fix this, we need to change sortquery() if we decide to keep the nulls embedded in the strings, as then strcasecmp will not suffice.

qpairs[] and qpairsdec[] probably need to be converted to a struct string or something that keeps a pointer and a length separate.

I've been working on a PR for this over the long weekend. I have a bug I'm trying to fix and then I just need to update the tests and the man page and it should be ready for review. Hoping to get some more work done on it this evening.

bagder commented

Fixed by #214