8000 merged branch matthijsvandenbos/matthijsvandenbos/link-handle-scheme … · combro2k/symfony@8e99eb0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8e99eb0

Browse files
committed
merged branch matthijsvandenbos/matthijsvandenbos/link-handle-scheme (PR symfony#7214)
This PR was merged into the 2.1 branch. Commits ------- 8f8ba38 [DomCrawler] fix handling of schemes by Link::getUri() Discussion ---------- [DomCrawler] fixed handling of schemes by Link::getUri() A link (anchor tag with an href attr) in pages crawled by the Crawler can contain any valid URI, including mailto: links. Currently this is not correctly supported by `Link::getUri`. Schemes that do not start with 'http' are treated as relative URIs and appenden to the base URI. This leads to strange URIs like this: http://foo.com/mailto:foo@bar.com Fixed `Link::getUri` to treat any URI with a schema part as an absolute URL. Updated the unit tests to test for this. --------------------------------------------------------------------------- by matthijsvandenbos at 2013-02-28T11:55:18Z Ok, I will update the pull request --------------------------------------------------------------------------- by matthijsvandenbos at 2013-02-28T12:25:45Z Fixed
2 parents 83382bc + 8f8ba38 commit 8e99eb0

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/Symfony/Component/DomCrawler/Link.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function getUri()
8989
$uri = trim($this->getRawUri());
9090

9191
// absolute URL?
92-
if (0 === strpos($uri, 'http')) {
92+
if (null !== parse_url($uri, PHP_URL_SCHEME)) {
9393
return $uri;
9494
}
9595

src/Symfony/Component/DomCrawler/Tests/LinkTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ public function getGetUriTests()
9393
array('?a=b', 'http://localhost/bar/', 'http://localhost/bar/?a=b'),
9494

9595
array('http://login.foo.com/foo', 'http://localhost/bar/', 'http://login.foo.com/foo'),
96+
array('https://login.foo.com/foo', 'https://localhost/bar/', 'https://login.foo.com/foo'),
97+
array('mailto:foo@bar.com', 'http://localhost/foo', 'mailto:foo@bar.com'),
9698

9799
array('?foo=2', 'http://localhost?foo=1', 'http://localhost?foo=2'),
98100
array('?foo=2', 'http://localhost/?foo=1', 'http://localhost/?foo=2'),

0 commit comments

Comments
 (0)
0