Giter VIP home page Giter VIP logo

Comments (14)

bagder avatar bagder commented on August 27, 2024

Oh right. I think I'll go with always-quoting the string and add escaping for a bunch of sensitive letters. What do you think about that?

from h2c.

salty-horse avatar salty-horse commented on August 27, 2024

I struggle with getting shells to understand me sometimes. Always quoting seems like a good idea.

from h2c.

bagder avatar bagder commented on August 27, 2024

That also makes letters such as semicolons not needing extra escaping.

from h2c.

salty-horse avatar salty-horse commented on August 27, 2024

Since the fix uses double quotes instead of single quotes, a shell will expand $ variables.

POST / HTTP/1.1
Host: localhost:8000
User-Agent: curl/7.47.0
Accept: */*
Content-Length: 143
Expect: 100-continue
Content-Type: multipart/form-data; boundary=------------------------fdbf5f7d1c2a96b2

--------------------------fdbf5f7d1c2a96b2
Content-Disposition: form-data; name="FOO"

$PATH
--------------------------fdbf5f7d1c2a96b2--

outputs:
curl --http1.1 --user-agent "curl/7.47.0" --form FOO="$PATH" https://localhost:8000/, which is bad.

from h2c.

bagder avatar bagder commented on August 27, 2024

Adding $ and \ to the regex now. Anything else?

from h2c.

salty-horse avatar salty-horse commented on August 27, 2024

Windows will expand %PATH%. I think single-quoting is the only way to avoid that if the output command should be cross-platform.

from h2c.

bagder avatar bagder commented on August 27, 2024

The windows command prompt doesn't support single quotes!

from h2c.

bagder avatar bagder commented on August 27, 2024

So quote % as well?

from h2c.

salty-horse avatar salty-horse commented on August 27, 2024

Impossible...? In Windows, % is quoted with %%, but in a POSIX shell, %% is treated as %%.

from h2c.

bagder avatar bagder commented on August 27, 2024

Hm, okey, so maybe ignore Windows for now and add an option to make the output "windows compatible" later.

from h2c.

slavaatsig avatar slavaatsig commented on August 27, 2024

Seems like best effort option is to provide the output suitable for the host platform with the option to generate output for other systems.

Looks like String::ShellQuote is a good bicycle for POSIX platforms.

If external library dependencies is a no-no, then for POSIX shells easiest way seems to use singular quotes so this is the only character that you will have to take care.

Reference: https://stackoverflow.com/a/24869016/7598113

from h2c.

bagder avatar bagder commented on August 27, 2024

BUGS
Only Bourne shell quoting is supported

... so it won't help us a whole lot.

from h2c.

slavaatsig avatar slavaatsig commented on August 27, 2024

For Microsoft® Windows™ platforms there is an MSDN blog-post about the wrong ways to do so.

TL;DR: See conclusions at the end of the post, it should enlighten on how to do it properly.

P.S.
It would be more helpful if Microsoft would posted about how to do it in a proper way instead.

from h2c.

bagder avatar bagder commented on August 27, 2024

still, that requires a "windows output mode" option to quote in that style instead

from h2c.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.