add "ascii+" as a special 'path-restrict' value (#4371)

pull/4403/head
Mike Fährmann 1 year ago
parent c79359eb3a
commit 9d67655397
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -206,7 +206,7 @@ Default
``"auto"`` ``"auto"``
Example Example
* ``"/!? (){}"`` * ``"/!? (){}"``
* ``{" ": "_", "/": "-", "|": "-", ":": "-", "*": "+"}`` * ``{" ": "_", "/": "-", "|": "-", ":": "_-_", "*": "_+_"}``
Description Description
| A string of characters to be replaced with the value of | A string of characters to be replaced with the value of
`path-replace <extractor.*.path-replace_>`__ `path-replace <extractor.*.path-replace_>`__
@ -219,7 +219,8 @@ Description
depending on the local operating system depending on the local operating system
* ``"unix"``: ``"/"`` * ``"unix"``: ``"/"``
* ``"windows"``: ``"\\\\|/<>:\"?*"`` * ``"windows"``: ``"\\\\|/<>:\"?*"``
* ``"ascii"``: ``"^0-9A-Za-z_."`` * ``"ascii"``: ``"^0-9A-Za-z_."`` (only ASCII digits, letters, underscores, and dots)
* ``"ascii+"``: ``"^0-9@-[\\]-{ #-)+-.;=!}~"`` (all ASCII characters except the ones not allowed by Windows)
Note: In a string with 2 or more characters, ``[]^-\`` need to be Note: In a string with 2 or more characters, ``[]^-\`` need to be
escaped with backslashes, e.g. ``"\\[\\]"`` escaped with backslashes, e.g. ``"\\[\\]"``

@ -98,6 +98,8 @@ class PathFormat():
restrict = "\\\\|/<>:\"?*" restrict = "\\\\|/<>:\"?*"
elif restrict == "ascii": elif restrict == "ascii":
restrict = "^0-9A-Za-z_." restrict = "^0-9A-Za-z_."
elif restrict == "ascii+":
restrict = "^0-9@-[\\]-{ #-)+-.;=!}~"
self.clean_segment = self._build_cleanfunc(restrict, replace) self.clean_segment = self._build_cleanfunc(restrict, replace)
remove = config("path-remove", "\x00-\x1f\x7f") remove = config("path-remove", "\x00-\x1f\x7f")

Loading…
Cancel
Save