aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2025-10-22 21:21:17 +0200
committerGravatar GitHub <noreply@github.com> 2025-10-22 21:21:17 +0200
commit1282d3a2709064cb847b8757409a7153449faa9d (patch)
tree862c46df5306b2254ff299c3ef9952623e38caa7 /app
parent6edb658dfb1586b9a290e2d8a5ce2f31d9bbb85d (diff)
PostgreSQL: compatibility with PCRE word boundary (#8141)
Allow the use of regex `\b` for word boundary (and `\B` for the opposite) even when using PostgreSQL. Follow up of: * https://github.com/FreshRSS/FreshRSS/pull/6706 For instance, `intitle:/\bnew\B/` will find *newest* but not *new* nor *renewal*. Useful in particular to minimise the differences between PHP and database in: * https://github.com/FreshRSS/FreshRSS/pull/7959
Diffstat (limited to 'app')
-rw-r--r--app/Models/EntryDAOPGSQL.php6
1 files changed, 6 insertions, 0 deletions
diff --git a/app/Models/EntryDAOPGSQL.php b/app/Models/EntryDAOPGSQL.php
index 6211b9a6b..91068919d 100644
--- a/app/Models/EntryDAOPGSQL.php
+++ b/app/Models/EntryDAOPGSQL.php
@@ -43,6 +43,12 @@ class FreshRSS_EntryDAOPGSQL extends FreshRSS_EntryDAOSQLite {
protected static function sqlRegex(string $expression, string $regex, array &$values): string {
$matches = static::regexToSql($regex);
if (isset($matches['pattern'])) {
+ $replacements = [ // Convert some of the PCRE regex syntax to PostgreSQL
+ '\\b' => '\\y', // matches only at the beginning or end of a word (was: backspace)
+ '\\B' => '\\Y', // matches only at a point that is not the beginning or end of a word (was: backslash)
+ ];
+ $matches['pattern'] = str_replace(array_keys($replacements), array_values($replacements), $matches['pattern']);
+
$matchType = $matches['matchType'] ?? '';
if (str_contains($matchType, 'm')) {
// newline-sensitive matching