php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #62844
Patch parse_url_relative_scheme2 revision 2012-08-19 23:31 UTC by ajf at ajf dot me
Patch parse_url_relative_scheme revision 2012-08-19 23:10 UTC by ajf at ajf dot me

Patch parse_url_relative_scheme2 for URL related Bug #62844

Patch version 2012-08-19 23:31 UTC

Return to Bug #62844 | Download this patch
This patch renders other patches obsolete

Obsolete patches:

Patch Revisions:

Developer: ajf@ajf.me

From 0cdda05eff4ed7c697bcd77a0d5ecb70597b3efe Mon Sep 17 00:00:00 2001
From: Andrew Faulds <ajf@ajf.me>
Date: Mon, 20 Aug 2012 00:03:55 +0100
Subject: [PATCH 1/2] bug #62844; relative URL schemes in parse_url()

---
 .../tests/url/parse_url_relative_scheme.phpt       |   11 +++++++++++
 ext/standard/url.c                                 |    2 ++
 2 files changed, 13 insertions(+)
 create mode 100644 ext/standard/tests/url/parse_url_relative_scheme.phpt

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
index 0000000..7c8952d
--- /dev/null
+++ b/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"
+}
+
diff --git a/ext/standard/url.c b/ext/standard/url.c
index 0555c7b..f1e48a1 100644
--- a/ext/standard/url.c
+++ b/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) == '/') { /* same-scheme (relative) URL */
+		s += 2;
 	} else {
 		just_path:
 		ue = s + length;
-- 
1.7.9.5


From 2b9a7a90c3d159b79ba54ca48d38f97b557921e2 Mon Sep 17 00:00:00 2001
From: Andrew Faulds <ajf@ajf.me>
Date: Mon, 20 Aug 2012 00:29:18 +0100
Subject: [PATCH 2/2] relative-scheme

---
 ext/standard/url.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ext/standard/url.c b/ext/standard/url.c
index f1e48a1..44a5680 100644
--- a/ext/standard/url.c
+++ b/ext/standard/url.c
@@ -204,7 +204,7 @@ 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 */
+	} else if (*s == '/' && *(s+1) == '/') { /* relative-scheme URL */
 		s += 2;
 	} else {
 		just_path:
-- 
1.7.9.5

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 16:01:33 2024 UTC