Skip to content

Commit 9ab6e87

Browse files
committed
Revert "Add support for RFC 3986 compliant URL schemes. #46."
This reverts commit bf41fb1.
1 parent 1ed79a4 commit 9ab6e87

File tree

3 files changed

+3
-13
lines changed

3 files changed

+3
-13
lines changed

src/Pdp/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*/
2020
class Parser
2121
{
22-
const SCHEME_PATTERN = '#^([a-zA-Z][a-zA-Z0-9+\-.]*)://#';
22+
const SCHEME_PATTERN = '#^(http|ftp)s?://#i';
2323
const IP_ADDRESS_PATTERN = '/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/';
2424

2525
/**

src/pdp-parse-url.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,10 @@
2424
*/
2525
function pdp_parse_url($url, $component = -1)
2626
{
27-
$pattern = '%([a-zA-Z][a-zA-Z0-9+\-.]*)?(:?//)?([^:/@?&=#\[\]]+)%usD';
28-
2927
$enc_url = preg_replace_callback(
30-
$pattern,
28+
'%[^:/@?&=#\[\]]+%usD',
3129
function ($matches) {
32-
$encoded = urlencode($matches[3]);
33-
return sprintf('%s%s%s', $matches[1], $matches[2], $encoded);
30+
return urlencode($matches[0]);
3431
},
3532
$url
3633
);
@@ -43,10 +40,6 @@ function ($matches) {
4340

4441
if (is_array($parts)) {
4542
foreach ($parts as $name => $value) {
46-
if ($name === 'scheme') {
47-
continue;
48-
}
49-
5043
$parts[$name] = urldecode($value);
5144
}
5245
} else {

tests/src/Pdp/ParserTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,6 @@ public function parseDataProvider()
185185
// Test ftp support - https://github.com/jeremykendall/php-domain-parser/issues/18
186186
array('ftp://www.waxaudio.com.au/audio/albums/the_mashening', 'com.au', 'waxaudio.com.au', 'www', 'www.waxaudio.com.au'),
187187
array('ftps://test.k12.ak.us', 'k12.ak.us', 'test.k12.ak.us', null, 'test.k12.ak.us'),
188-
// Test support for RFC 3986 compliant schemes
189-
// https://github.com/jeremykendall/php-domain-parser/issues/46
190-
array('fake-scheme+RFC-3986.compliant://example.com', 'com', 'example.com', null, 'example.com'),
191188
array('http://localhost', null, null, null, 'localhost'),
192189
array('test.museum', 'museum', 'test.museum', null, 'test.museum'),
193190
array('bob.smith.name', 'name', 'smith.name', 'bob', 'bob.smith.name'),

0 commit comments

Comments
 (0)