[grade=B] fix: PCRE delimiter collision (# in char class) broke YT extraction — switch to ~ delimiter, verified in PHP CLI

This commit is contained in:
Krystie
2026-09-07 16:28:07 -07:00
parent 2b65194cdb
commit 05b9b4cc57
+1 -1
View File
@@ -718,7 +718,7 @@ function beep_format_content($text) {
* Returns the 11-char video ID or ''.
*/
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 $m[1][0];