From bc6b232d7cf20ccd0a8cf59bdb78ed4128470e98 Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 26 Dec 2022 23:49:55 +1100 Subject: [PATCH] Clean extra non-printable chars (#4110) - \x00 (null character) - \x7F (DEL character) --- InvenTree/InvenTree/helpers.py | 4 ++-- InvenTree/templates/js/translated/helpers.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/InvenTree/InvenTree/helpers.py b/InvenTree/InvenTree/helpers.py index 82b32ec4d5..cf0a046def 100644 --- a/InvenTree/InvenTree/helpers.py +++ b/InvenTree/InvenTree/helpers.py @@ -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) diff --git a/InvenTree/templates/js/translated/helpers.js b/InvenTree/templates/js/translated/helpers.js index eac2774671..9313bf32e7 100644 --- a/InvenTree/templates/js/translated/helpers.js +++ b/InvenTree/templates/js/translated/helpers.js @@ -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, '');