Projet

Général

Profil

Bug #7204

Bad xml encoding with mod_cas

Ajouté par Emmanuel Lacour il y a presque 9 ans. Mis à jour il y a plus de 6 ans.

Statut:
Fermé
Priorité:
Normal
Assigné à:
-
Catégorie:
-
Version cible:
-
Début:
11 mai 2015
Echéance:
% réalisé:

100%

Temps estimé:
Patch proposed:
Non
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')

Révisions associées

Révision e31e3f64 (diff)
Ajouté par Benjamin Dauvergne il y a presque 9 ans

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

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

Historique

#1

Mis à jour par Benjamin Dauvergne il y a presque 9 ans

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

Mis à jour par Emmanuel Lacour il y a presque 9 ans

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

Mis à jour par Benjamin Dauvergne il y a presque 9 ans

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

#4

Mis à jour par Benjamin Dauvergne il y a presque 9 ans

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

Mis à jour par Benjamin Dauvergne il y a presque 9 ans

  • Statut changé de Nouveau à Résolu (à déployer)
  • % réalisé changé de 0 à 100
#6

Mis à jour par Benjamin Dauvergne il y a environ 8 ans

  • Statut changé de Résolu (à déployer) à Solution déployée
#7

Mis à jour par Benjamin Dauvergne il y a plus de 6 ans

  • Statut changé de Solution déployée à Fermé

Formats disponibles : Atom PDF