From c83e9f6ca56842d5add92643a322cbc2df1e7423 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Tue, 4 Jan 2011 21:56:37 +0000 Subject: [PATCH] foundation for filtering binary string values (for example, replacement of non readable chars with #) --- lib/core/common.py | 4 +++- lib/core/settings.py | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/core/common.py b/lib/core/common.py index 25f9f619d..d98d0e549 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -1806,7 +1806,7 @@ def removeDynamicContent(page): return page -def filterStringValue(value, regex): +def filterStringValue(value, regex, replace=None): """ Returns string value consisting only of chars satisfying supplied regular @@ -1818,6 +1818,8 @@ def filterStringValue(value, regex): for char in value: if re.search(regex, char): retVal += char + elif replace: + retVal += replace return retVal diff --git a/lib/core/settings.py b/lib/core/settings.py index a8935c3ee..73c2b04d4 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -52,6 +52,7 @@ DUMP_STOP_MARKER = "__STOP__" PAYLOAD_DELIMITER = "\x00" CHAR_INFERENCE_MARK = "%c" +READABLE_CHAR_REGEX = r'[\ -~]' # coefficient used for a time-based query delay checking (must be >= 7) TIME_STDEV_COEFF = 10