Skip to content

Commit 4d8a49a

Browse files
committed
more standard way to display hex encoded char (\xff instead of \ff) also compatible with python representation
1 parent 05a0e1d commit 4d8a49a

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

lib/core/convert.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def safecharencode(value):
153153
for char in SAFE_ENCODE_SLASH_REPLACEMENTS:
154154
retVal = retVal.replace(char, repr(char).strip('\''))
155155

156-
retVal = reduce(lambda x, y: x + (y if (y in string.printable or ord(y) > 255) else '\%02x' % ord(y)), retVal, unicode())
156+
retVal = reduce(lambda x, y: x + (y if (y in string.printable or ord(y) > 255) else '\\x%02x' % ord(y)), retVal, unicode())
157157

158158
elif isinstance(value, list):
159159
for i in xrange(len(value)):
@@ -173,7 +173,7 @@ def safechardecode(value):
173173
while True:
174174
match = regex.search(retVal)
175175
if match:
176-
retVal = retVal.replace(match.group("result"), binascii.unhexlify(match.group("result").lstrip('\\')))
176+
retVal = retVal.replace(match.group("result"), binascii.unhexlify(match.group("result").lstrip('\\x')))
177177
else:
178178
break
179179

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@
306306
IGNORE_PARAMETERS = ("__VIEWSTATE", "__EVENTARGUMENT", "__EVENTTARGET", "__EVENTVALIDATION", "ASPSESSIONID", "ASP.NET_SESSIONID", "JSESSIONID", "CFID", "CFTOKEN")
307307

308308
# Regex used for recognition of hex encoded characters
309-
HEX_ENCODED_CHAR_REGEX = r"(?P<result>\\[0-9A-Fa-f]{2})"
309+
HEX_ENCODED_CHAR_REGEX = r"(?P<result>\\x[0-9A-Fa-f]{2})"
310310

311311
# Raw chars that will be safe encoded to their slash (\) representations (e.g. newline to \n)
312312
SAFE_ENCODE_SLASH_REPLACEMENTS = "\\\t\n\r\x0b\x0c"

0 commit comments

Comments
 (0)