Skip to content

Comments

trurl: allow "control bytes" in JSON output#333

Merged
bagder merged 1 commit intomasterfrom
bagder/json-control-bytes
Aug 27, 2024
Merged

trurl: allow "control bytes" in JSON output#333
bagder merged 1 commit intomasterfrom
bagder/json-control-bytes

Conversation

@bagder
Copy link
Member

@bagder bagder commented Aug 27, 2024

For example when doing

trurl 'http://example.org/%18' --json

Adapted and extended test cases to verify.

Fixes #262
Reported-by: Emanuele Torre

For example when doing

    trurl 'http://example.org/%18' --json

Adapted and extended test cases to verify.

Fixes #262
Reported-by: Emanuele Torre
@bagder bagder merged commit a12ed0f into master Aug 27, 2024
@bagder bagder deleted the bagder/json-control-bytes branch August 27, 2024 09:01
@emanuele6
Copy link
Collaborator

@bagder
This patch fixed --json, but not -g {path}:

$ ./trurl 'http://example.org/%18' -g '{path}'
trurl note: URL decode error, most likely because of rubbish in the input (path)

@bagder
Copy link
Member Author

bagder commented Aug 27, 2024

Correct, as I like to focus on one thing per issue but also that the "regular" output is different and might need other considerations. Should we really allow control codes to be output like this?

@emanuele6
Copy link
Collaborator

Correct, as I like to focus on one thing per issue

I mentioned it because this PR closed #262

Should we really allow control codes to be output like this?

I don't see why not, also note that this is only causing errors for non-query: gets:

$ trurl -g '{fragment}' 'https://example.org/compiler#def%20main:%20%0a%09print%20"hello"'
trurl note: URL decode error, most likely because of rubbish in the input (fragment)

$ trurl -g '{query:code}' 'https://example.org/compiler?code=def%20main:%0a%09print%20"hello"'                                                
def main:
	print "hello"

Incidentally, unrelated, but I have noticed that -g {query:blah} doesn't convert +=>

$ trurl -g '{query:code}' 'https://example.org/compiler?code=def+main:%0a%09print+"hello"'
def+main:
	print+"hello"

@bagder
Copy link
Member Author

bagder commented Aug 27, 2024

Incidentally, unrelated, but I have noticed that -g {query:blah} doesn't convert +=>

It does now! 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Components with control characters don't appear in --json output, and non-urlencoded --get fails

2 participants