Commit 78326867 authored by Evan Simpson's avatar Evan Simpson

Completely fix bug #721 by using attrEscape instead of cgi.escape for

dynamic attribute values as well as static values.
parent 335cac9a
...@@ -8,6 +8,9 @@ Zope Changes ...@@ -8,6 +8,9 @@ Zope Changes
Bugs fixed Bugs fixed
- Collector #721: Entities in tal:attribute values weren't
properly escaped.
- Collector #851: Traversable.py: A bare try..except shadowed - Collector #851: Traversable.py: A bare try..except shadowed
conflict errors conflict errors
......
...@@ -24,7 +24,7 @@ from cgi import escape ...@@ -24,7 +24,7 @@ from cgi import escape
from StringIO import StringIO from StringIO import StringIO
from DocumentTemplate.DT_Util import ustr from DocumentTemplate.DT_Util import ustr
from TALDefs import TAL_VERSION, TALError, METALError from TALDefs import TAL_VERSION, TALError, METALError, attrEscape
from TALDefs import isCurrentVersion, getProgramVersion, getProgramMode from TALDefs import isCurrentVersion, getProgramVersion, getProgramMode
from TALGenerator import TALGenerator from TALGenerator import TALGenerator
from TranslationContext import TranslationContext from TranslationContext import TranslationContext
...@@ -336,7 +336,7 @@ class TALInterpreter: ...@@ -336,7 +336,7 @@ class TALInterpreter:
if value is None: if value is None:
value = name value = name
else: else:
value = '%s="%s"' % (name, escape(value, 1)) value = '%s="%s"' % (name, attrEscape(value))
return 1, name, value return 1, name, value
def attrAction_tal(self, item): def attrAction_tal(self, item):
...@@ -369,7 +369,7 @@ class TALInterpreter: ...@@ -369,7 +369,7 @@ class TALInterpreter:
value = translated value = translated
if value is None: if value is None:
value = name value = name
value = '%s="%s"' % (name, escape(value, 1)) value = '%s="%s"' % (name, attrEscape(value))
return ok, name, value return ok, name, value
bytecode_handlers["<attrAction>"] = attrAction bytecode_handlers["<attrAction>"] = attrAction
......
...@@ -221,7 +221,7 @@ class OutputPresentationTestCase(TestCaseBase): ...@@ -221,7 +221,7 @@ class OutputPresentationTestCase(TestCaseBase):
self.compare(INPUT, EXPECTED) self.compare(INPUT, EXPECTED)
def check_entities(self): def check_entities(self):
INPUT = ('<img tal:define="foo nothing" ' INPUT = ('<img tal:attributes="alt default" '
'alt="&a; &#1; &#x0a; &a &#45 &; &#0a; <>" />') 'alt="&a; &#1; &#x0a; &a &#45 &; &#0a; <>" />')
EXPECTED = ('<img alt="&a; &#1; &#x0a; ' EXPECTED = ('<img alt="&a; &#1; &#x0a; '
'&amp;a &amp;#45 &amp;; &amp;#0a; &lt;&gt;" />\n') '&amp;a &amp;#45 &amp;; &amp;#0a; &lt;&gt;" />\n')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment