Bug #24393
crash lors du rendu d'un template appelant une variable contenant du non-ascii
Statut:
Fermé
Priorité:
Normal
Assigné à:
-
Version cible:
-
Début:
09 juin 2018
Echéance:
% réalisé:
0%
Temps estimé:
Patch proposed:
Oui
Planning:
Description
Exception: type = '<type 'exceptions.UnicodeEncodeError'>', value = ''ascii' codec can't encode character u'\xe9' in position 9: ordinal not in range(128)' Stack trace (most recent call first): File "/home/fred/src/eo/venv1.11/local/lib/python2.7/site-packages/django/template/base.py", line 931, in _resolve_lookup 929 current = context.template.engine.string_if_invalid 930 else: > 931 raise 932 933 return current locals: bit = u'form_var_\xe9l\xe9phant' ... File "/home/fred/src/eo/venv1.11/local/lib/python2.7/site-packages/django/template/base.py", line 849, in resolve 847 if self.lookups is not None: 848 # We're dealing with a variable that needs to be resolved > 849 value = self._resolve_lookup(context) 850 else: 851 # We're dealing with a literal, so it's already been "resolved" ... File "/home/fred/src/eo/wcs/wcs/qommon/template.py", line 526, in variable_resolve 524 525 def variable_resolve(self, context): > 526 value = variable_resolve_orig(self, context) 527 if isinstance(value, SafeString): 528 return SafeUnicode(value, 'utf-8') ...
Fichiers
Révisions associées
Historique
Mis à jour par Frédéric Péters il y a presque 6 ans
- Fichier 0001-misc-don-t-crash-templates-on-variables-with-invalid.patch 0001-misc-don-t-crash-templates-on-variables-with-invalid.patch ajouté
- Statut changé de Nouveau à En cours
- Patch proposed changé de Non à Oui
On profite du fait qu'on monkeypatch déjà variable_resolve pour corriger ça mais le problème existe aussi dans les autres applications (pas testé mais vraisemblablement corrigé avec Python 3 qui autorise des identifiants unicode).
Mis à jour par Thomas Noël il y a presque 6 ans
Ack en ajoutant éventuellement "(and refuse non-ascii names)" à la fin du commentaire juste au dessus.
Mis à jour par Frédéric Péters il y a presque 6 ans
- Statut changé de En cours à Résolu (à déployer)
Poussé avec l'ajout d'un commentaire.
commit f7090e752457d0992586b3a0dc23ddea8de54f31 Author: Frédéric Péters <fpeters@entrouvert.com> Date: Sat Jun 9 10:45:48 2018 +0200 misc: don't crash templates on variables with invalid characters (#24393)
Mis à jour par Frédéric Péters il y a plus de 5 ans
- Statut changé de Résolu (à déployer) à Solution déployée
misc: don't crash templates on variables with invalid characters (#24393)