Bug #7204
Bad xml encoding with mod_cas
100%
Description
Using mod_cas, I get this error in apache error log:
MOD_AUTH_CAS: error parsing CASv2 response: XML parser error code: unknown encoding (18)
Error is gone by replacing utf8 by utf-8 in cas/views.py:
- diff
Naur /var/backups/vim/views.py~ /usr/share/pyshared/authentic2_idp_cas/views.py/var/backups/vim/views.py~ 2015-05-11 23:24:34.434041777 0200
--
++ /usr/share/pyshared/authentic2_idp_cas/views.py 2015-05-11 23:24:34.434041777 0200@ -267,7 +267,7
@
user.text = unicode(identifier)
self.provision_pgt(request, st, success)
self.provision_attributes(request, st, success)
- return HttpResponse(ET.tostring(root, encoding='utf8'),
return HttpResponse(ET.tostring(root, encoding='utf-8'),
content_type='text/xml')def provision_attributes(self, request, st, success):
@ -390,7 +390,7
@
success = ET.SubElement(root, PROXY_SUCCESS_ELT)
proxy_ticket = ET.SubElement(success, PROXY_TICKET_ELT)
proxy_ticket.text = pt.ticket_id
- return HttpResponse(ET.tostring(root, encoding='utf8'),
+ return HttpResponse(ET.tostring(root, encoding='utf-8'),
content_type='text/xml')
Associated revisions
History
Updated by Benjamin Dauvergne about 8 years ago
I do not think there is a difference between utf8, utf-8 or utf_8 with Python. Are you sure this fixed your problem ?
Updated by Emmanuel Lacour about 8 years ago
Le 12/05/2015 16:52, redmine@entrouvert.com a écrit :
La demande #7204 a été mise à jour par Benjamin Dauvergne.
I do not think there is a difference between utf8, utf-8 or utf_8 with Python. Are you sure this fixed your problem ?
sure, but I think the true problem is not within python, but with apache
mod auth_cas ...
thought updating your code should make it compatible with the cas apache
plugin.
Updated by Benjamin Dauvergne about 8 years ago
Ok I understand the problem now, it's not the encoding but the name given to the encoding in the XML output.
Updated by Benjamin Dauvergne about 8 years ago
It's a strange behaviour from ElementTree, it is more rigourous than Python on the encoding name.
In [3]: ET.tostring(ET.Element('coucou'), encoding='utf8') Out[3]: "<?xml version='1.0' encoding='utf8'?>\n<coucou />" In [4]: ET.tostring(ET.Element('coucou'), encoding='utf-8') Out[4]: '<coucou />'
Updated by Benjamin Dauvergne about 8 years ago
- Status changed from Nouveau to Résolu (à déployer)
- % Done changed from 0 to 100
Appliqué par commit authentic2|e31e3f643105874767df4dbc0ae9af4a0a8df8a2.
Updated by Benjamin Dauvergne over 7 years ago
- Status changed from Résolu (à déployer) to Solution déployée
authentic_idp_cas/views: fix utf-8 encoding name (fixes #7204)
ElementTree is more rigorous than Python on the UTF-8 encoding name.