collective / sphinxcontrib-httpexample

Adds example directive for sphinx-contrib httpdomain
23 stars 20 forks source link

Quote the URL if it contains `&` characters in curl/httpie/wget examples #17

Closed dokai closed 6 years ago

dokai commented 6 years ago

Currently, if the URL contains any query parameters (or anything else that is a special shell character) the example command won't be copy-pasteable as-is into a shell and the user must manually quote the URL to make the command runnable.

This PR adds shell quoting for the URL to accommodate the common use of of having multiple & separated query parameters in the URL. The URL will be quoted only when necessary.

coveralls commented 6 years ago

Coverage Status

Coverage decreased (-0.7%) to 96.181% when pulling 512f3f20c0ddfe48328e4545a46602bb2fa91ae4 on dokai:shell-quote into 42a02baea36aa947cc4dee09d8b1cbf80cb66599 on collective:master.

dokai commented 6 years ago

I didn't realize that shlex.quote is not available in Python 2.x. I'll rework the PR if there is interest in merging the feature.

datakurre commented 6 years ago

@dokai Yes there is :) Please, do.

dokai commented 6 years ago

Sure, will do. It seems that there is an existing backport of shlex.quote available in https://github.com/chrissimpkins/shellescape. Would you be open to adding that as a dependency or rather have the implementation in this repo?

The amount of code is rather small so re-implementing/copying with attribution would not be an issue either.

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.07%) to 96.939% when pulling d49fe4f48ed361a4da92a6eb99fcd805d8bc4be0 on dokai:shell-quote into 42a02baea36aa947cc4dee09d8b1cbf80cb66599 on collective:master.

dokai commented 6 years ago

Added the Python 2.x fix from @datakurre and rebased against current master.

datakurre commented 6 years ago

Thanks. I’ll make a release only tomorrow due to PloneConf party tonight ;)