]> granicus.if.org Git - curl/commitdiff
URL parser: cut off '#' fragments from URLs (better)
authorDaniel Stenberg <daniel@haxx.se>
Tue, 6 Nov 2012 22:17:57 +0000 (23:17 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 6 Nov 2012 22:17:57 +0000 (23:17 +0100)
The existing logic only cut off the fragment from the separate 'path'
buffer which is used when sending HTTP to hosts. The buffer that held
the full URL used for proxies were not dealt with. It is now.

Test case 5 was updated to use a fragment on a URL over a proxy.

Bug: http://curl.haxx.se/bug/view.cgi?id=3579813

lib/url.c
tests/data/test5

index 5ffaa730562c30dcbb2b3bc3523dd82a47aaf347..601d8d364c0862e95f0fc9e844c947f77164bff3 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -3987,9 +3987,17 @@ static CURLcode parseurlandfillconn(struct SessionHandle *data,
      last part of the URI. We are looking for the first '#' so that we deal
      gracefully with non conformant URI such as http://example.com#foo#bar. */
   fragment = strchr(path, '#');
-  if(fragment)
+  if(fragment) {
     *fragment = 0;
 
+    /* we know the path part ended with a fragment, so we know the full URL
+       string does too and we need to cut it off from there so it isn't used
+       over proxy */
+    fragment = strchr(data->change.url, '#');
+    if(fragment)
+      *fragment = 0;
+  }
+
   /*
    * So if the URL was A://B/C#D,
    *   protop is A
index 7a0ebd73053e66bae8f91ba9b369f904f90e81f1..b62f1a127a6bfd2a426c7c04b8dab789d1e6e749 100644 (file)
@@ -29,7 +29,7 @@ http
 HTTP over proxy
  </name>
  <command>
-http://%HOSTIP:%HTTPPORT/we/want/that/page/5 -x %HOSTIP:%HTTPPORT
+http://%HOSTIP:%HTTPPORT/we/want/that/page/5#5 -x %HOSTIP:%HTTPPORT
 </command>
 </client>