Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tool_writeout_json: fix encoding of control characters #11414

Closed
wants to merge 1 commit into from

Conversation

emanuele6
Copy link
Contributor

@emanuele6 emanuele6 commented Jul 9, 2023

Control characters without a shorthand e.g. %06 were being encoded as "u0006" instead of "\u0006".

See curl/trurl#214 (comment).


I tried to add a test for this that gets a response with Foo: %hex[%06%07%08]hex% in the headers, and checks that header_json also contains "foo": "\u0006\u0007\b", but nghttpx doesn't seem to like that.

Maybe I could use a test that checks the entire -w %{json} output, and tests filename_effecitive? That actually doesn't seem to work because curl -Ow '%{json}\n' example.org/file%06.html downloads to file%06.html, and outputs "filename_effective": "file%06.html"; when using -O the path from the URL is not url decoded.

Testing this would be easier using the --expand-foo '{{json:something}}' introduced by #11346, so maybe that PR could add a test for this instead.

Control characters without a special escape sequence e.g. %00 or %06
were being encoded as "u0006" instead of "\u0006".
@bagder
Copy link
Member

bagder commented Jul 9, 2023

I'm fine with delaying adding a test case for this until #11346 has been merged, which will not happen until the feature window opens again.

@bagder bagder closed this in 8484ad0 Jul 9, 2023
@bagder
Copy link
Member

bagder commented Jul 9, 2023

Thanks!

@emanuele6 emanuele6 deleted the fixjsonctl branch July 9, 2023 16:58
@emanuele6
Copy link
Contributor Author

emanuele6 commented Jul 9, 2023

I figure out a way this could be tested:

curl -w '%{json}\n' -o $'foo\x06\x07\x08' file:///dev/null

Before this patch, that will output "foou0006u0007\b" instead of "foo\u0006\u0007\b" for filename_effective, but it will actually download to a file named "foo" followed 0x06 0x07 0x08.

bch pushed a commit to bch/curl that referenced this pull request Jul 19, 2023
Control characters without a special escape sequence e.g. %00 or %06
were being encoded as "u0006" instead of "\u0006".

Ref: curl/trurl#214 (comment)
Closes curl#11414
ptitSeb pushed a commit to wasix-org/curl that referenced this pull request Sep 25, 2023
Control characters without a special escape sequence e.g. %00 or %06
were being encoded as "u0006" instead of "\u0006".

Ref: curl/trurl#214 (comment)
Closes curl#11414
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

2 participants