Skip to content

Commit

Permalink
[DomCrawler] [HttpFoundation] Make Content-Type attributes identifi…
Browse files Browse the repository at this point in the history
…cation case-insensitive
  • Loading branch information
Matthieu Prat committed Oct 25, 2013
1 parent 2a637b1 commit 17a2d66
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/Component/DomCrawler/Crawler.php
Expand Up @@ -97,7 +97,7 @@ public function addContent($content, $type = null)
}

$charset = null;
if (false !== $pos = strpos($type, 'charset=')) {
if (false !== $pos = stripos($type, 'charset=')) {
$charset = substr($type, $pos + 8);
if (false !== $pos = strpos($charset, ';')) {
$charset = substr($charset, 0, $pos);
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpFoundation/Response.php
Expand Up @@ -223,7 +223,7 @@ public function prepare(Request $request)
$charset = $this->charset ?: 'UTF-8';
if (!$headers->has('Content-Type')) {
$headers->set('Content-Type', 'text/html; charset='.$charset);
} elseif (0 === strpos($headers->get('Content-Type'), 'text/') && false === strpos($headers->get('Content-Type'), 'charset')) {
} elseif (0 === stripos($headers->get('Content-Type'), 'text/') && false === stripos($headers->get('Content-Type'), 'charset')) {
// add the charset
$headers->set('Content-Type', $headers->get('Content-Type').'; charset='.$charset);
}
Expand Down

0 comments on commit 17a2d66

Please sign in to comment.