Skip to content

A free, self-hostable news aggregator…

Set limits for regex during search (#8913)

Inverle5e18e968874f
diff --git a/app/Models/SystemConfiguration.php b/app/Models/SystemConfiguration.php
index 14143b89c..3b17ce96e 100644
--- a/app/Models/SystemConfiguration.php
+++ b/app/Models/SystemConfiguration.php
@@ -38,7 +38,10 @@ final class FreshRSS_SystemConfiguration extends Minz_Configuration {
public static function init(string $config_filename, ?string $default_filename = null): FreshRSS_SystemConfiguration {
parent::register('system', $config_filename, $default_filename);
try {
- return parent::get('system');
+ $conf = parent::get('system');
+ ini_set('pcre.backtrack_limit', $conf->limits['regex_backtrack_limit']);
+ ini_set('pcre.recursion_limit', $conf->limits['regex_recursion_limit']);
+ return $conf;
} catch (Minz_ConfigurationNamespaceException $ex) {
FreshRSS::killApp($ex->getMessage());
}
diff --git a/config.default.php b/config.default.php
index d54141a71..73988c4cc 100644
--- a/config.default.php
+++ b/config.default.php
@@ -142,6 +142,10 @@ return [
# Max amount of bytes that are allowed for upload of custom favicon
'max_favicon_upload_size' => 1048576, # 1 MiB
+
+ # Limits for regex, useful to limit regex during user searches
+ 'regex_backtrack_limit' => 10000,
+ 'regex_recursion_limit' => 100,
],
# Options used by cURL when making HTTP requests, e.g. when the SimplePie library retrieves feeds.