A percent sign breaks your service, sometimes.
See original GitHub issueTodo
- Add special parameter
q
for queries, that can be used with--data-urlencode
- Add parameters
answer
andquestion
to specify them explicitly - Add support of
q
into the cht.sh command line client
Details
I was doing a search over your curl service for query, trying to untangle a printf %s
for bash question, which seemed a reasonable query. I get an nginx failure: 400 Bad Request nginx/1.13.12
For example this query produces an error: https://cheat.sh/python/print %s
But these work fine: http://cht.sh/python/% https://cheat.sh/python3/print list http://cht.sh/python/printf %25s
The last one was what I intended. Percent signs appear to be interpreted in transit between curl and nginx server side URL rewriting. Your server says eh bro that’s not a valid URL, barf.
https://www.w3schools.com/tags/ref_urlencode.ASP
But curl works fine on the terminal, showing me that maybe the problem’s on client side, as long as URL encoding is done in a way that makes your server happy, then all is well?
$ curl cht.sh/bash/printf %s
# bash - SPRINTF in shell scripting?
var=$(printf 'FILE=_%s_%s.dat' "$val1" "$val2")
...
This http://cht.sh/python/printf?myparameter#myhash only searches for printf
One answer is: “It’s the user’s responsibility to url-encode all queries so nginx is happy, and take care not to search for slashes, questionmarks, percent signs or any URL escape chars”. Is this the case or is there a cleverer solution for me to pass you a literal string over curl?
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top GitHub Comments
but I think it still would be great to have a special query like discussed above (i.e.
q=
)Probably, it would be better to add several additional parameters, like
question
,answer
and already mentionedq
, so that your query could be written like:?q=rmse/0/1
So, that means, the following should be done:
q
for queries, that can be used with--data-urlencode
q
into the cht.sh command line clientanswer
andquestion
to specify them explicitly