Check for valid scheme in YouTube and Twitter URLs.

This commit is contained in:
flash 2023-01-25 13:04:13 +00:00
parent ad773e72a7
commit 5fe283a2a7
2 changed files with 4 additions and 1 deletions

View File

@ -14,7 +14,7 @@ final class TwitterLookup implements \Uiharu\ILookup {
];
public function match(Url $url): bool {
if(!in_array($url->getHost(), self::TWITTER_DOMAINS))
if(!$url->isWeb() || !in_array($url->getHost(), self::TWITTER_DOMAINS))
return false;
return preg_match('#^/@?(?:[A-Za-z0-9_]{1,20})/status(?:es)?/([0-9]+)/?$#', $url->getPath())

View File

@ -36,6 +36,9 @@ final class YouTubeLookup implements \Uiharu\ILookup {
}
public function match(Url $url): bool {
if(!$url->isWeb())
return false;
$urlHost = $url->getHost();
if(self::isShortDomain($urlHost))
return true;