[Asterisk-code-review] syncami: wrap utf-8 string before parsing (testsuite[16])
Kevin Harwell
asteriskteam at digium.com
Mon Sep 10 12:23:52 CDT 2018
Kevin Harwell has uploaded this change for review. ( https://gerrit.asterisk.org/10066
Change subject: syncami: wrap utf-8 string before parsing
......................................................................
syncami: wrap utf-8 string before parsing
For some reason in some older versions of Python directly passing a utf-8 string
to HeaderParser's parsestr method would not parse the data correctly. However,
wrapping it in a StringIO object first works for all versions.
Change-Id: I24af2df707983accc9298da095c018b1aaf963e3
---
M lib/python/asterisk/syncami.py
1 file changed, 5 insertions(+), 3 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/66/10066/1
diff --git a/lib/python/asterisk/syncami.py b/lib/python/asterisk/syncami.py
index 5482400..634b1ba 100644
--- a/lib/python/asterisk/syncami.py
+++ b/lib/python/asterisk/syncami.py
@@ -15,6 +15,7 @@
# python 3 import
from urllib.parse import urlencode
+from StringIO import StringIO
from email.parser import HeaderParser
try:
from httplib import *
@@ -93,7 +94,8 @@
if res.status != 200:
raise InvalidAMIResponse(res)
self.cookie = res.getheader('set-cookie', None)
- data = res.read().decode('utf-8')
- parser = HeaderParser()
- return parser.parsestr(data)
+ data = StringIO(res.read().decode('utf-8'))
+ res = HeaderParser().parse(data)
+ data.close()
+ return res
--
To view, visit https://gerrit.asterisk.org/10066
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: testsuite
Gerrit-Branch: 16
Gerrit-MessageType: newchange
Gerrit-Change-Id: I24af2df707983accc9298da095c018b1aaf963e3
Gerrit-Change-Number: 10066
Gerrit-PatchSet: 1
Gerrit-Owner: Kevin Harwell <kharwell at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180910/c0b583d3/attachment.html>
More information about the asterisk-code-review
mailing list