diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index e133aec869427..ba209ab5adecc 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -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('/\]+charset *= *["\']?([a-zA-Z\-0-9]+)/i', $content, $matches)) { + preg_match('/\]+charset *= *["\']?([a-zA-Z\-0-9_:.]+)/i', $content, $matches)) { $charset = $matches[1]; } diff --git a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php index 7b93d4d14ccfa..44c3a56d28700 100644 --- a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php @@ -233,6 +233,10 @@ public function testAddContent() $crawler = new Crawler(); $crawler->addContent('中文'); $this->assertEquals('中文', $crawler->filterXPath('//span')->text(), '->addContent() guess wrong charset'); + + $crawler = new Crawler(); + $crawler->addContent(mb_convert_encoding('日本語', 'SJIS', 'UTF-8')); + $this->assertEquals('日本語', $crawler->filterXPath('//body')->text(), '->addContent() can recognize "Shift_JIS" in html5 meta charset tag'); } /** diff --git a/src/Symfony/Component/Validator/Constraints/Optional.php b/src/Symfony/Component/Validator/Constraints/Optional.php index 36b615f3f3a5c..dab8b4371f2c7 100644 --- a/src/Symfony/Component/Validator/Constraints/Optional.php +++ b/src/Symfony/Component/Validator/Constraints/Optional.php @@ -13,7 +13,7 @@ /** * @Annotation - * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) + * @Target({"ANNOTATION"}) * * @author Bernhard Schussek */ diff --git a/src/Symfony/Component/Validator/Constraints/Required.php b/src/Symfony/Component/Validator/Constraints/Required.php index 66ced405e96ff..bd77a909f97fb 100644 --- a/src/Symfony/Component/Validator/Constraints/Required.php +++ b/src/Symfony/Component/Validator/Constraints/Required.php @@ -13,7 +13,7 @@ /** * @Annotation - * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) + * @Target({"ANNOTATION"}) * * @author Bernhard Schussek */