From c0da7d935dc76c1a927d608e99303c820433e4f4 Mon Sep 17 00:00:00 2001 From: Gmer4Lfe Date: Sun, 9 Aug 2026 22:55:29 -0400 Subject: [PATCH] Delimit the subreddit filter with ~ so it actually runs The pattern used # as its delimiter and excluded a literal # inside the character class, so PCRE ended the pattern early and the match never fired. It read as the filter doing nothing. The unit test missed it by asserting against a retyped copy of the regex rather than the one in the file, which is the only version that matters. --- Plugin/unraid/include/ai_web.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Plugin/unraid/include/ai_web.php b/Plugin/unraid/include/ai_web.php index 52b357c..e0f7fa3 100644 --- a/Plugin/unraid/include/ai_web.php +++ b/Plugin/unraid/include/ai_web.php @@ -188,7 +188,10 @@ function vv_ai_web_degoog(string $q): ?array { $rows = []; foreach ($d['results'] ?? [] as $r) { $url = (string)($r['url'] ?? ''); - if (preg_match('#^https?://(?:[a-z0-9-]+\.)*reddit\.com/r/[^/?#]+/?$#i', $url)) continue; + // Delimited with ~, not #. The character class has to exclude a literal # (a fragment), + // and with # as the delimiter PCRE ends the pattern there and the match silently never + // fires — which is exactly what happened, and it looked like the filter doing nothing. + if (preg_match('~^https?://(?:[a-z0-9-]+\.)*reddit\.com/r/[^/?#]+/?$~i', $url)) continue; $rows[] = ['title' => $r['title'] ?? '', 'url' => $url, 'snippet' => ($r['snippet'] ?? '') !== '' ? $r['snippet'] : ($r['content'] ?? '')];