- Affected version
- 2.2.13
PHP:
if ($response->getStatusCode() == 200)
{
try
{
$json = json_decode($jsonText, true);
if (!empty($json['title']))
{
$title = $json['title'];
}
else if (!empty($json['author_name']))
{
$title = $json['author_name'];
}
$validOembed = true;
}
catch (\Exception $e)
{
$error = \XF::phraseDeferred('returned_data_is_not_json');
}
json_decode
doesn't throw an exception if it can't decode, it will just return null
in which case this code will just happily continue without setting any title but treating the data as valid (which later on saves nonsense like HTML in internal_data/oembed-cache
)Suggested Fix
Use
GuzzleHttp\json_decode
which does throw an exception on decode error so the code works as expected.