[grade=B] fix: PCRE delimiter collision (# in char class) broke YT extraction — switch to ~ delimiter, verified in PHP CLI
This commit is contained in:
@@ -718,7 +718,7 @@ function beep_format_content($text) {
|
|||||||
* Returns the 11-char video ID or ''.
|
* Returns the 11-char video ID or ''.
|
||||||
*/
|
*/
|
||||||
function beep_youtube_id_from_text($text) {
|
function beep_youtube_id_from_text($text) {
|
||||||
if (!preg_match_all('#(?<![\w.-])(?:https?://)?(?:www\.|m\.)?(?:youtube\.com/(?:watch\?[^#\s]*v=|shorts/|embed/|live/)|youtu\.be/)([A-Za-z0-9_-]{11})(?![A-Za-z0-9_-])#i', (string) $text, $m)) {
|
if (!preg_match_all('~(?<![\w.-])(?:https?://)?(?:www\.|m\.)?(?:youtube\.com/(?:watch\?[^#\s]*v=|shorts/|embed/|live/)|youtu\.be/)([A-Za-z0-9_-]{11})(?![A-Za-z0-9_-])~i', (string) $text, $m)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
return $m[1][0];
|
return $m[1][0];
|
||||||
|
|||||||
Reference in New Issue
Block a user