Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 93838fb

Browse files
committed
"patch" for a problem reported by black zero (v = self._sslobj.write(data)...UnicodeError)
1 parent 96c3ffd commit 93838fb

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

lib/core/common.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1892,3 +1892,15 @@ def filterListValue(value, regex):
18921892
return retVal
18931893
else:
18941894
return value
1895+
1896+
def unicodeToSafeHTMLValue(value):
1897+
"""
1898+
Returns HTML representation of unicode
1899+
string value safe for sending over HTTP(s)
1900+
"""
1901+
retVal = value
1902+
if value:
1903+
for char in value:
1904+
if ord(char) > 127:
1905+
retVal = retVal.replace(char, "&#%d;" % ord(char))
1906+
return retVal

lib/request/connect.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from lib.core.common import clearConsoleLine
2323
from lib.core.common import getCurrentThreadData
2424
from lib.core.common import getFilteredPageContent
25+
from lib.core.common import unicodeToSafeHTMLValue
2526
from lib.core.common import getUnicode
2627
from lib.core.common import logHTTPTraffic
2728
from lib.core.common import readInput
@@ -150,6 +151,11 @@ def getPage(**kwargs):
150151
for key, item in auxHeaders.items():
151152
headers[key] = item
152153

154+
for key, item in headers.items():
155+
headers[key] = unicodeToSafeHTMLValue(item)
156+
157+
post = unicodeToSafeHTMLValue(post)
158+
153159
if method:
154160
req = MethodRequest(url, post, headers)
155161
req.set_method(method)

0 commit comments

Comments
 (0)