Commit 0f6a4160 authored by Fred Drake's avatar Fred Drake

XML attribute names are case-sensitive; do not lower-case them!

This corresponds to Zope 3 collector issue 129.
http://collector.zope.org/Zope3-dev/129
parent 0c189b9b
......@@ -113,14 +113,15 @@ _attr_re = re.compile(r"\s*([^\s]+)\s+([^\s].*)\Z", re.S)
_subst_re = re.compile(r"\s*(?:(text|structure)\s+)?(.*)\Z", re.S)
del re
def parseAttributeReplacements(arg):
def parseAttributeReplacements(arg, xml):
dict = {}
for part in splitParts(arg):
m = _attr_re.match(part)
if not m:
raise TALError("Bad syntax in attributes:" + `part`)
name, expr = m.group(1, 2)
name = name.lower()
if not xml:
name = name.lower()
if dict.has_key(name):
raise TALError("Duplicate attribute name in attributes:" + `part`)
dict[name] = expr
......
......@@ -646,7 +646,8 @@ class TALGenerator:
self.pushProgram()
if attrsubst or i18nattrs:
if attrsubst:
repldict = TALDefs.parseAttributeReplacements(attrsubst)
repldict = TALDefs.parseAttributeReplacements(attrsubst,
self.xml)
else:
repldict = {}
if i18nattrs:
......
......@@ -72,7 +72,7 @@ class TALParser(XMLParser):
for key, value in attrlist:
key, keybase, keyns = self.fixname(key)
ns = keyns or namens # default to tag namespace
item = key.lower(), value
item = key, value
if ns == 'metal':
metaldict[keybase] = value
item = item + ("metal",)
......
<?xml version="1.0"?>
<body xmlns:tal="http://xml.zope.org/namespaces/tal">
<img href="foo" Alt="bar"
<ImG href="foo" Alt="bar"
tal:attributes="Href string:about:foo;alT string:baz" />
</body>
<?xml version="1.0"?>
<body>
<img href="about:foo" alt="baz"/>
<ImG href="foo" Alt="bar" alT="baz" Href="about:foo"/>
</body>
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