Project

General

Profile

Bug #7204

Bad xml encoding with mod_cas

Added by Emmanuel Lacour over 7 years ago. Updated about 5 years ago.

Status:
Fermé
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
11 May 2015
Due date:
% Done:

100%

Estimated time:
Patch proposed:
No
Planning:

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:

  1. 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

Revision e31e3f64 (diff)
Added by Benjamin Dauvergne over 7 years ago

authentic_idp_cas/views: fix utf-8 encoding name (fixes #7204)

ElementTree is more rigorous than Python on the UTF-8 encoding name.

History

#1

Updated by Benjamin Dauvergne over 7 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 ?

#2

Updated by Emmanuel Lacour over 7 years ago

Le 12/05/2015 16:52, 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.

#3

Updated by Benjamin Dauvergne over 7 years ago

Ok I understand the problem now, it's not the encoding but the name given to the encoding in the XML output.

#4

Updated by Benjamin Dauvergne over 7 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 />'
#5

Updated by Benjamin Dauvergne over 7 years ago

  • Status changed from Nouveau to Résolu (à déployer)
  • % Done changed from 0 to 100
#6

Updated by Benjamin Dauvergne almost 7 years ago

  • Status changed from Résolu (à déployer) to Solution déployée
#7

Updated by Benjamin Dauvergne about 5 years ago

  • Status changed from Solution déployée to Fermé

Also available in: Atom PDF