Skip to content

Commit

Permalink
Fix data encoding only for content-type in "text/html; charset=UTF-8"
Browse files Browse the repository at this point in the history
  • Loading branch information
StephSako committed Dec 19, 2022
1 parent 7a772f5 commit fea072f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Service/FFTTClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ private function send(string $uri): array
$content = preg_replace('/&(?!#?[a-z0-9]+;)/', '&', $content);
$content = html_entity_decode($content);

// Some requests have a different header than others, whose data must be correctly encoded
if ($response->hasHeader('content-type') && $response->getHeader('content-type')[0] == 'text/html; charset=UTF-8') {
$content = mb_convert_encoding($content, 'ISO-8859-1', 'UTF-8');
}

$xml = simplexml_load_string($content, 'SimpleXMLElement', LIBXML_NOCDATA);

/** @var string $encoded */
Expand Down

0 comments on commit fea072f

Please sign in to comment.