jqlang / jq

Command-line JSON processor

Home Page:https://jqlang.github.io/jq/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

@uri is not percent-encoding all reserved characters

dhawal55 opened this issue · comments

@uri documentation in manual:
Applies percent-encoding, by mapping all reserved URI characters to a %XX sequence.

However, it does not percent-encode certain reserved characters like ! ( ) *.

echo '"!()*#$&+,/:;=?@[]"' | jq -r '@uri' 
!()*%23%24%26%2B%2C%2F%3A%3B%3D%3F%40%5B%5D

see also
whatwg/url#369 "Need an "unreserved" character set (and better define how to percent-encode arbitrary strings)"

The single quote ' is also reserved but not encoded by @uri.

Using the test string at https://developers.google.com/maps/documentation/urls/url-encoding --

$ jqMaster --version
jq-1.6-129-g80052e5-dirty

$ jqMaster -n $'"! * \' ( ) ; : @ & = + $ , / ? % # [ ]" | @uri'
"!%20*%20'%20(%20)%20%3B%20%3A%20%40%20%26%20%3D%20%2B%20%24%20%2C%20%2F%20%3F%20%25%20%23%20%5B%20%5D"