From faec542493eedf989f0703a1b4cedb74025bd9e2 Mon Sep 17 00:00:00 2001 From: Thomas Mangin Date: Wed, 6 May 2020 16:24:46 +0100 Subject: debug: T2426: remove invisible characters when printing --- python/vyos/debug.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/python/vyos/debug.py b/python/vyos/debug.py index 1a042cbb4..91431a7bb 100644 --- a/python/vyos/debug.py +++ b/python/vyos/debug.py @@ -81,10 +81,17 @@ def enabled(flag): return _fromenv(flag) or _fromfile(flag) +def _remove_invisible(string): + for char in ('\0', '\a', '\b', '\f', '\v'): + string = string.replace(char, '') + return string + + def _format(flag, message): """ format a log message """ + message = _remove_invisible(message) return f'DEBUG/{flag.upper():<7} {message}\n' -- cgit v1.2.3