Univention Bugzilla – Attachment 5814 Details for
Bug 33520
UDM module process dies when response contains binary data
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
fix encoding recursively if decoding fails
33520.patch (text/plain), 1.05 KB, created by
Florian Best
on 2014-03-05 15:02:53 CET
(
hide
)
Description:
fix encoding recursively if decoding fails
Filename:
MIME Type:
Creator:
Florian Best
Created:
2014-03-05 15:02:53 CET
Size:
1.05 KB
patch
obsolete
>Index: message.py >=================================================================== >--- message.py (Revision 48275) >+++ message.py (Arbeitskopie) >@@ -116,7 +116,10 @@ > if _type == Message.REQUEST: > type = 'REQUEST' > if mimetype == MIMETYPE_JSON: >- data = json.dumps( body ) >+ try: >+ data = json.dumps( body ) >+ except UnicodeDecodeError: >+ data = json.dumps(_fix_encoding(body)) > else: > data = body > args = '' >@@ -316,6 +319,21 @@ > del body['options'] > return Message._formattedMessage(self._id, self._type, self.mimetype, self.command, body, self.arguments) > >+ >+def _fix_encoding(data): >+ if isinstance(data, bytestring): >+ try: >+ data.decode('utf-8') >+ except UnicodeDecodeError: >+ data = data.decode('iso8859-1').encode('utf-8') >+ elif isinstance(data, (list, tuple)): >+ data = data.__class__(_fix_encoding(d) for d in data) >+ elif isinstance(data, dict): >+ data = data.__class__((_fix_encoding(k), _fix_encoding(v)) for k, v in data.iteritems()) >+ >+ return data >+ >+ > if __name__ == '__main__': > # encode > auth = Request( 'AUTH' )
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 33520
: 5814