Clean extra non-printable chars (#4110)

- \x00 (null character)
- \x7F (DEL character)
This commit is contained in:
Oliver 2022-12-26 23:49:55 +11:00 committed by GitHub
parent 95dc78a61f
commit bc6b232d7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -966,8 +966,8 @@ def remove_non_printable_characters(value: str, remove_newline=True, remove_asci
if remove_ascii:
# Remove ASCII control characters
# Note that we do not sub out 0x0A (\n) here, it is done separately below
cleaned = regex.sub(u'[\x01-\x09]+', '', cleaned)
cleaned = regex.sub(u'[\x0b-\x1F]+', '', cleaned)
cleaned = regex.sub(u'[\x00-\x09]+', '', cleaned)
cleaned = regex.sub(u'[\x0b-\x1F\x7F]+', '', cleaned)
if remove_newline:
cleaned = regex.sub(u'[\x0a]+', '', cleaned)

View File

@ -456,7 +456,7 @@ function sanitizeInputString(s, options={}) {
}
// Remove ASCII control characters
s = s.replace(/[\x01-\x1F]+/g, '');
s = s.replace(/[\x00-\x1F\x7F]+/g, '');
// Remove Unicode control characters
s = s.replace(/[\p{C}]+/gu, '');