Menu

#2235 URL parameters passed to curl/wget are incorrectly subject to Windows path mangling

MSYS
assigned
None
Feature
none
Unknown
False
2014-09-18
2014-09-18
Jason Gross
No

Reporting upstream from https://github.com/msysgit/git/issues/250#issuecomment-56017745

D:\Documents\GitHub\HoTT [refl-subu-prod +4 ~0 -0 !]> sh
sh.exe"-3.1$ curl -v 'http://google.com?foo=/foo'

* Adding handle: conn: 0x4a8668
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x4a8668) send_pipe: 1, recv_pipe: 0
* About to connect() to google.com port 80 (#0)
*   Trying 4.53.56.93...
* Connected to google.com (4.53.56.93) port 80 (#0)
> GET /?foo=C:/Users/Jason/AppData/Local/GitHub/PortableGit_6d98349f44ba975cf6c762a720f8259a267ea445/foo HTTP/1.1
> User-Agent: curl/7.30.0
> Host: google.com
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Location: http://www.google.com/?foo=C:/Users/Jason/AppData/Local/GitHub/PortableGit_6d98349f44ba975cf6c762a720f8259a
67ea445/foo
< Content-Type: text/html; charset=UTF-8
< Date: Thu, 18 Sep 2014 00:09:01 GMT
< Expires: Sat, 18 Oct 2014 00:09:01 GMT
< Cache-Control: public, max-age=2592000
* Server gws is not blacklisted
< Server: gws
< Content-Length: 316
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: SAMEORIGIN
< Alternate-Protocol: 80:quic,p=0.002
<
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/?foo=C:/Users/Jason/AppData/Local/GitHub/PortableGit_6d98349f44ba975cf6c762a720f8259a267
a445/foo">here</A>.
</BODY></HTML>
* Connection #0 to host google.com left intact

Note that it replaces ?foo=/foo with ?foo=C:/Users/Jason/AppData/Local/GitHub/PortableGit_6d98349f44ba975cf6c762a720f8259a 67ea445/foo. A workaround is to replace /foo with %2Ffoo. But it would be nice to not need this workaround.

Discussion

  • Keith Marshall

    Keith Marshall - 2014-09-18
    • summary: Edit New issue URL parameters passed to curl/wget are incorrectly subject to Windows path mangling --> URL parameters passed to curl/wget are incorrectly subject to Windows path mangling
    • status: unread --> assigned
    • assigned_to: Cesar Strauss
    • Type: Bug --> Feature
     
  • Keith Marshall

    Keith Marshall - 2014-09-18

    I've been asking for years, for a mechanism to disable path name translation for specific arguments, when invoking native Windows applications. This is a well known issue, and not considered a bug, but still merits consideration as a feature request; we've been short changed on this, for way too long.

    In this particular situation, the LHS of the (apparent) assignment is correctly parsed, and identified as a URL which should not be translated. However, the RHS becomes a new candidate for translation, and is identified as the absolute POSIX path /foo, which the translation rules say should become $MSYS_ROOT_DEVICE:/$MSYS_ROOT_PATH/foo, (illustrated using showargv in place of curl):--

    $ showargv -v http://google.com?foo=/foo
    command: c:\mingw\bin\showargv.exe -v "http://google.com?foo=C:/MinGW/msys/1.0/foo"
    argv[00]: c:\mingw\bin\showargv.exe
    argv[01]: -v
    argv[02]: http://google.com?foo=C:/MinGW/msys/1.0/foo
    

     
    The documented way to avoid translation is:--

    $ showargv -v http://google.com?foo=//foo
    command: c:\mingw\bin\showargv.exe -v "http://google.com?foo=/foo"
    argv[00]: c:\mingw\bin\showargv.exe
    argv[01]: -v
    argv[02]: http://google.com?foo=/foo
    

     
    so, in this particular case, simply adopting existing documented behaviour would seem to be simpler than any more sophisticated translation avoidance mechanism, but such a mechanism remains an outstanding requirement.

     
MongoDB Logo MongoDB