Skip to content

Commit

Permalink
Merge branch '2.1'
Browse files Browse the repository at this point in the history
* 2.1:
  Added Base64 encoding, decoding to MongoDBProfilerStorage
  Fix duplicated code and a field name
  refactor src/Symfony/Component/Translation/Loader/MoFileLoader.php
  fixed typo
  Update src/Symfony/Component/Validator/Resources/translations/validators.pl.xlf
  fixed issue #5596 (Broken DOM with the profiler's toolbar set in position top)
  [Form] Fixed the testsuite for PHPUnit 3.6 as travis still uses it
  added dirs generated by build-data.php in locale component to .gitignore
  [Process] Fixed bug introduced by 7bafc69f38a3512eb15aad506959a4e7be162e52.
  [Process][Tests] Prove process fail (Add more test case)
  [Process][Tests] Prove process fail
  [HttpFoundation] Fixed the tests
  [DomCrawler] Added test for supported encodings by mbstring
  [Config] Fixed preserving keys in associative arrays
  [Console] Fixed return value for Command::run
  [Locale] Fixed tests
  [Console] Fix some input tests
  [Filesystem] Fixed tests on Windows
  [Config] Fixed tests on Windows
  • Loading branch information
fabpot committed Sep 28, 2012
2 parents ef5ca2b + fadb297 commit faa80e6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Crawler.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function addHtmlContent($content, $charset = 'UTF-8')
$dom = new \DOMDocument('1.0', $charset);
$dom->validateOnParse = true;

if (function_exists('mb_convert_encoding')) {
if (function_exists('mb_convert_encoding') && in_array(strtolower($charset), array_map('strtolower', mb_list_encodings()))) {
$content = mb_convert_encoding($content, 'HTML-ENTITIES', $charset);
}

Expand Down
11 changes: 11 additions & 0 deletions Tests/CrawlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ public function testAddHtmlContentCharset()
$this->assertEquals('Tiếng Việt', $crawler->filterXPath('//div')->text());
}

/**
* @covers Symfony\Component\DomCrawler\Crawler::addHtmlContent
*/
public function testAddHtmlContentUnsupportedCharset()
{
$crawler = new Crawler();
$crawler->addHtmlContent(file_get_contents(__DIR__.'/Fixtures/windows-1250.html'), 'Windows-1250');

$this->assertEquals('Žťčýů', $crawler->filterXPath('//p')->text());
}

/**
* @covers Symfony\Component\DomCrawler\Crawler::addHtmlContent
*/
Expand Down
8 changes: 8 additions & 0 deletions Tests/Fixtures/windows-1250.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=windows-1250">
</head>
<body>
<p>Žèýù</p>
</body>
</html>

0 comments on commit faa80e6

Please sign in to comment.