Skip to content

Commit

Permalink
Merge branch '2.3' into 2.4
Browse files Browse the repository at this point in the history
* 2.3:
  [Validator] Remove property and method targets from the optional and required constraints.
  [DomCrawler] Fixed charset detection in html5 meta charset tag
  • Loading branch information
fabpot committed May 31, 2014
2 parents 53d5eca + b8247a3 commit f1970a7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/Symfony/Component/DomCrawler/Crawler.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ public function addContent($content, $type = null)
}
}

// http://www.w3.org/TR/encoding/#encodings
// http://www.w3.org/TR/REC-xml/#NT-EncName
if (null === $charset &&
preg_match('/\<meta[^\>]+charset *= *["\']?([a-zA-Z\-0-9]+)/i', $content, $matches)) {
preg_match('/\<meta[^\>]+charset *= *["\']?([a-zA-Z\-0-9_:.]+)/i', $content, $matches)) {
$charset = $matches[1];
}

Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ public function testAddContent()
$crawler = new Crawler();
$crawler->addContent('<html><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><span>中文</span></html>');
$this->assertEquals('中文', $crawler->filterXPath('//span')->text(), '->addContent() guess wrong charset');

$crawler = new Crawler();
$crawler->addContent(mb_convert_encoding('<html><head><meta charset="Shift_JIS"></head><body>日本語</body></html>', 'SJIS', 'UTF-8'));
$this->assertEquals('日本語', $crawler->filterXPath('//body')->text(), '->addContent() can recognize "Shift_JIS" in html5 meta charset tag');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Validator/Constraints/Optional.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

/**
* @Annotation
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
* @Target({"ANNOTATION"})
*
* @author Bernhard Schussek <[email protected]>
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Validator/Constraints/Required.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

/**
* @Annotation
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
* @Target({"ANNOTATION"})
*
* @author Bernhard Schussek <[email protected]>
*/
Expand Down

0 comments on commit f1970a7

Please sign in to comment.