mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-18 01:41:14 -06:00
Merge commit from fork
* Add safe regex matching with timeouts and validation * Remove redundant length check * Remove timeouterror workaround
This commit is contained in:
@@ -71,6 +71,7 @@ from documents.parsers import is_mime_type_supported
|
||||
from documents.permissions import get_document_count_filter_for_user
|
||||
from documents.permissions import get_groups_with_only_permission
|
||||
from documents.permissions import set_permissions_for_object
|
||||
from documents.regex import validate_regex_pattern
|
||||
from documents.templating.filepath import validate_filepath_template_and_render
|
||||
from documents.templating.utils import convert_format_str_to_template_format
|
||||
from documents.validators import uri_validator
|
||||
@@ -141,10 +142,10 @@ class MatchingModelSerializer(serializers.ModelSerializer):
|
||||
and self.initial_data["matching_algorithm"] == MatchingModel.MATCH_REGEX
|
||||
):
|
||||
try:
|
||||
re.compile(match)
|
||||
except re.error as e:
|
||||
validate_regex_pattern(match)
|
||||
except ValueError as e:
|
||||
raise serializers.ValidationError(
|
||||
_("Invalid regular expression: %(error)s") % {"error": str(e.msg)},
|
||||
_("Invalid regular expression: %(error)s") % {"error": str(e)},
|
||||
)
|
||||
return match
|
||||
|
||||
|
||||
Reference in New Issue
Block a user