Merge pull request #12117 from MrPetovan/bug/12113-malformed-url-containsLink
Suppress InvalidArgument exceptions handling URLs in Model\Item::containsLink
This commit is contained in:
commit
eecd5020ac
|
@ -3094,11 +3094,20 @@ class Item
|
||||||
{
|
{
|
||||||
// Make sure that for example site parameters aren't used when testing if the link is contained in the body
|
// Make sure that for example site parameters aren't used when testing if the link is contained in the body
|
||||||
$urlparts = parse_url($url);
|
$urlparts = parse_url($url);
|
||||||
if (!empty($urlparts)) {
|
if (empty($urlparts)) {
|
||||||
unset($urlparts['query']);
|
return false;
|
||||||
unset($urlparts['fragment']);
|
}
|
||||||
|
|
||||||
|
unset($urlparts['query']);
|
||||||
|
unset($urlparts['fragment']);
|
||||||
|
|
||||||
|
try {
|
||||||
$url = (string)Uri::fromParts($urlparts);
|
$url = (string)Uri::fromParts($urlparts);
|
||||||
} else {
|
} catch (\InvalidArgumentException $e) {
|
||||||
|
DI::logger()->notice('Invalid URL', ['$url' => $url, '$urlparts' => $urlparts]);
|
||||||
|
/* See https://github.com/friendica/friendica/issues/12113
|
||||||
|
* Malformed URLs will result in a Fatal Error
|
||||||
|
*/
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3111,12 +3120,14 @@ class Item
|
||||||
if (strpos($body, $url)) {
|
if (strpos($body, $url)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ([0, 1, 2] as $size) {
|
foreach ([0, 1, 2] as $size) {
|
||||||
if (preg_match('#/photo/.*-' . $size . '\.#ism', $url) &&
|
if (preg_match('#/photo/.*-' . $size . '\.#ism', $url) &&
|
||||||
strpos(preg_replace('#(/photo/.*)-[012]\.#ism', '$1-' . $size . '.', $body), $url)) {
|
strpos(preg_replace('#(/photo/.*)-[012]\.#ism', '$1-' . $size . '.', $body), $url)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user