diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index 3fc881b841..03c6effebc 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -145,8 +145,9 @@ class Crawler extends \SplObjectStorage $base = $this->filterXPath('descendant-or-self::base')->extract(array('href')); - if (count($base)) { - $this->uri = current($base); + $baseHref = current($base); + if (count($base) && !empty($baseHref)) { + $this->uri = $baseHref; } } diff --git a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php index 30401b9d75..8aac5d082f 100644 --- a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php @@ -80,6 +80,18 @@ class CrawlerTest extends \PHPUnit_Framework_TestCase $this->assertEquals('Tiếng Việt', $crawler->filterXPath('//div')->text()); } + /** + * @covers Symfony\Component\DomCrawler\Crawler::addHtmlContent + */ + public function testAddHtmlContentInvalidBaseTag() + { + $crawler = new Crawler(null, 'http://symfony.com'); + + $crawler->addHtmlContent('