]> granicus.if.org Git - php/commitdiff
bug #62844; relative URL schemes in parse_url()
authorAndrew Faulds <ajf@ajf.me>
Sun, 19 Aug 2012 23:03:55 +0000 (00:03 +0100)
committerStanislav Malyshev <stas@php.net>
Mon, 20 Aug 2012 05:15:58 +0000 (22:15 -0700)
ext/standard/tests/url/parse_url_relative_scheme.phpt [new file with mode: 0644]
ext/standard/url.c

diff --git a/ext/standard/tests/url/parse_url_relative_scheme.phpt b/ext/standard/tests/url/parse_url_relative_scheme.phpt
new file mode 100644 (file)
index 0000000..7c8952d
--- /dev/null
@@ -0,0 +1,11 @@
+--TEST--
+Test parse_url() function: Checks relative URL schemes (e.g. "//example.com")
+--FILE--
+<?php
+var_dump(parse_url('//example.org'));
+--EXPECT--
+array(1) {
+  ["host"]=>
+  string(11) "example.org"
+}
+
index 0555c7b65aa8a0aa3f91950f7d4b5551c60443c8..f1e48a1a5f7472ac8e4c8ba7e571d1302f08a003 100644 (file)
@@ -204,6 +204,8 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length)
                } else {
                        goto just_path;
                }
+       } else if (*s == '/' && *(s+1) == '/') { /* same-scheme (relative) URL */
+               s += 2;
        } else {
                just_path:
                ue = s + length;