Skip to content

Loading…

bug #62844; relative URL schemes in parse_url() #169

Closed
wants to merge 2 commits into from

3 participants

@TazeTSchnitzel

'//example.com' is parsed correctly.

https://bugs.php.net/bug.php?id=62844

@travisbot

This pull request fails (merged 0cdda05 into cd18e20).

@travisbot

This pull request fails (merged 2b9a7a9 into cd18e20).

@php-pulls

Comment on behalf of stas at php.net:

merged

@php-pulls php-pulls closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 0 deletions.
  1. +11 −0 ext/standard/tests/url/parse_url_relative_scheme.phpt
  2. +2 −0 ext/standard/url.c
View
11 ext/standard/tests/url/parse_url_relative_scheme.phpt
@@ -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"
+}
+
View
2 ext/standard/url.c
@@ -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) == '/') { /* relative-scheme URL */
+ s += 2;
} else {
just_path:
ue = s + length;
Something went wrong with that request. Please try again.