diff options
| author | Andrew Dolgov <fox@fakecake.org> | 2025-03-28 18:36:11 +0300 |
|---|---|---|
| committer | Andrew Dolgov <fox@fakecake.org> | 2025-03-28 18:36:11 +0300 |
| commit | 043162b0ebe7b086bf7b19d5b4585ada36a4f9d5 (patch) | |
| tree | d986001448ca56d383d86650d407ec9679315988 /classes | |
| parent | 42ea2ebec04c39f210b64cca82786d7392a4f2a7 (diff) | |
enforce maximum length on resulting rule regexp match, highlight based on strings with stripped tags
Diffstat (limited to 'classes')
| -rw-r--r-- | classes/Pref_Filters.php | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/classes/Pref_Filters.php b/classes/Pref_Filters.php index 799277fa0..3e97309ac 100644 --- a/classes/Pref_Filters.php +++ b/classes/Pref_Filters.php @@ -181,10 +181,12 @@ class Pref_Filters extends Handler_Protected { $can_highlight_content = false; $can_highlight_title = false; - $matches[] = $rule['regexp_matches'][0]; + $rule_regexp_match = mb_substr(strip_tags($rule['regexp_matches'][0]), 0, 200); + + $matches[] = $rule_regexp_match; if (in_array($rule['type'], ['content', 'both'])) { - $match_index = mb_strpos($entry_content_text, $rule['regexp_matches'][0]); + $match_index = mb_strpos($entry_content_text, $rule_regexp_match); $content_preview = truncate_string(mb_substr($entry_content_text, $match_index), 200); if ($match_index > 0) @@ -228,7 +230,7 @@ class Pref_Filters extends Handler_Protected { 'feed_title' => $entry['feed_title'], 'date' => mb_substr($entry['date_entered'], 0, 16), 'content_preview' => $content_preview, - 'matched_rules' => $matched_rules, + 'matched_rules' => $matched_rules, // TODO shorten object passed to frontend ]; } } |