diff options
author | Jesús <heckyel@hyperbola.info> | 2019-05-24 19:56:14 -0500 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2019-05-24 19:56:14 -0500 |
commit | 05082c0666905547f4acee9d07325aed82e803f2 (patch) | |
tree | 57be73c8f25f1de2539886647056a32e4584dd09 /tools | |
parent | 0b7502445af12fa2ea0b3c3563776132dd9167a4 (diff) | |
download | ytlibre-05082c0666905547f4acee9d07325aed82e803f2.tar.lz ytlibre-05082c0666905547f4acee9d07325aed82e803f2.tar.xz ytlibre-05082c0666905547f4acee9d07325aed82e803f2.zip |
relax regex
Diffstat (limited to 'tools')
-rw-r--r-- | tools/processor.php | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/tools/processor.php b/tools/processor.php index 3b96487..e22e70f 100644 --- a/tools/processor.php +++ b/tools/processor.php @@ -9,10 +9,18 @@ $baselink = htmlspecialchars($_GET['link']); $urlexists = url_exists( $baselink ); if ($urlexists === true) { - // Regex - filter URL id is match[5] - // Testing into → https://regexr.com/4ej96 - $rx = '/^((?:https?:)?\/\/)?((?:www|m)\.)?((?:youtube\.com|youtu.be|invidio\.us|invidiou\.sh|invidious\.snopyta\.org))(\/(?:[\w\-]+\?v=|embed\/|v\/)?)([\w\-]+)(\S+)?$/'; + $rx = '/^((?:https?:)?\/\/)? # Optional protocol + ((?:www|m)[.])? # Optional sub-domain + ((?:youtube[.]com| + youtu[.]be| + invidio[.]us| + invidiou[.]sh| + invidious[.]kabi[.]tk| + invidious[.]snopyta[.]org)) # URL supports + (\/(?:[\w\-]+\?v=|embed\/|v\/)?) # Parameters (embed, v) + ([\w\-]+) # Video id of 11 + (\S+)?$/mx'; preg_match($rx, $baselink, $match); // Testing if id → 11 characters @@ -21,7 +29,6 @@ if ($urlexists === true) { } else { header('Location: index.php'); } - } else { header('Location: index.php'); } |