aboutsummaryrefslogtreecommitdiff
path: root/app/Models/EntryDAOPGSQL.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2024-09-06 09:35:58 +0200
committerGravatar GitHub <noreply@github.com> 2024-09-06 09:35:58 +0200
commit1a552bd60eab4a4b940d3896376b599e155d7da0 (patch)
treee3872dfc1bc51ed52a88bc22fc7582e858314a71 /app/Models/EntryDAOPGSQL.php
parent35a7634e68d87ad4da46c96ee8066e8c681f8d18 (diff)
Regex search (#6706)
* Regex search fix https://github.com/FreshRSS/FreshRSS/issues/3549 * Fix PHPStan * Fix escape * Fix ungreedy * Initial support for regex search in PostgreSQL and MySQL * Improvements, support MySQL * Fix multiline * Add support for SQLite * A few tests * Added author: and inurl: support, documentation * author example * Remove \b for now * Disable regex sanitization for now * Fix getInurlRegex * getNotInurlRegex * Quotes for inurl: * Fix test * Fix quoted tags + regex for tags https://github.com/FreshRSS/FreshRSS/issues/6761 * Fix wrong regex detection * Add MariaDB * Fix logic * Increase requirements for MySQL and MariaDB Check support for multiline mode in MySQL * Remove sanitizeRegexes() * Allow searching HTML code Allow searching for instance `/<pre>/` Fix https://github.com/FreshRSS/FreshRSS/issues/6775#issuecomment-2331769883 * Doc regex search HTML * Fix Doctype
Diffstat (limited to 'app/Models/EntryDAOPGSQL.php')
-rw-r--r--app/Models/EntryDAOPGSQL.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/app/Models/EntryDAOPGSQL.php b/app/Models/EntryDAOPGSQL.php
index 8adeffe9e..fe157308c 100644
--- a/app/Models/EntryDAOPGSQL.php
+++ b/app/Models/EntryDAOPGSQL.php
@@ -23,6 +23,32 @@ class FreshRSS_EntryDAOPGSQL extends FreshRSS_EntryDAOSQLite {
return rtrim($sql, ' ;') . ' ON CONFLICT DO NOTHING';
}
+ #[\Override]
+ protected static function sqlRegex(string $expression, string $regex, array &$values): string {
+ $matches = static::regexToSql($regex);
+ if (isset($matches['pattern'])) {
+ $matchType = $matches['matchType'] ?? '';
+ if (str_contains($matchType, 'm')) {
+ // newline-sensitive matching
+ $matches['pattern'] = '(?m)' . $matches['pattern'];
+ }
+ $values[] = $matches['pattern'];
+ if (str_contains($matchType, 'i')) {
+ // case-insensitive matching
+ return "{$expression} ~* ?";
+ } else {
+ // case-sensitive matching
+ return "{$expression} ~ ?";
+ }
+ }
+ return '';
+ }
+
+ #[\Override]
+ protected function registerSqlFunctions(string $sql): void {
+ // Nothing to do for PostgreSQL
+ }
+
/** @param array<string|int> $errorInfo */
#[\Override]
protected function autoUpdateDb(array $errorInfo): bool {