[Zope-Checkins] CVS: Zope/lib/python/TAL - TALDefs.py:1.28.4.2 TALGenerator.py:1.55.4.4 TALParser.py:1.19.4.2

Chris McDonough chrism@zope.com
Fri, 3 Jan 2003 01:35:13 -0500


Update of /cvs-repository/Zope/lib/python/TAL
In directory cvs.zope.org:/tmp/cvs-serv27993

Modified Files:
      Tag: chrism-install-branch
	TALDefs.py TALGenerator.py TALParser.py 
Log Message:
Merging chrism-install-branch with HEAD (hopefully for one of the last
times).



=== Zope/lib/python/TAL/TALDefs.py 1.28.4.1 => 1.28.4.2 ===
--- Zope/lib/python/TAL/TALDefs.py:1.28.4.1	Sat Sep 28 21:40:35 2002
+++ Zope/lib/python/TAL/TALDefs.py	Fri Jan  3 01:34:40 2003
@@ -35,6 +35,7 @@
     "use-macro",
     "define-slot",
     "fill-slot",
+    "slot",
     ]
 
 KNOWN_TAL_ATTRIBUTES = [
@@ -119,6 +120,7 @@
         if not m:
             raise TALError("Bad syntax in attributes:" + `part`)
         name, expr = m.group(1, 2)
+        name = name.lower()
         if dict.has_key(name):
             raise TALError("Duplicate attribute name in attributes:" + `part`)
         dict[name] = expr
@@ -163,3 +165,24 @@
         if opcode == "version":
             return version
     return None
+
+import re
+_ent1_re = re.compile('&(?![A-Z#])', re.I)
+_entch_re = re.compile('&([A-Z][A-Z0-9]*)(?![A-Z0-9;])', re.I)
+_entn1_re = re.compile('&#(?![0-9X])', re.I)
+_entnx_re = re.compile('&(#X[A-F0-9]*)(?![A-F0-9;])', re.I)
+_entnd_re = re.compile('&(#[0-9][0-9]*)(?![0-9;])')
+del re
+
+def attrEscape(s):
+    """Replace special characters '&<>' by character entities,
+    except when '&' already begins a syntactically valid entity."""
+    s = _ent1_re.sub('&amp;', s)
+    s = _entch_re.sub(r'&amp;\1', s)
+    s = _entn1_re.sub('&amp;#', s)
+    s = _entnx_re.sub(r'&amp;\1', s)
+    s = _entnd_re.sub(r'&amp;\1', s)
+    s = s.replace('<', '&lt;')
+    s = s.replace('>', '&gt;')
+    s = s.replace('"', '&quot;')
+    return s


=== Zope/lib/python/TAL/TALGenerator.py 1.55.4.3 => 1.55.4.4 ===
--- Zope/lib/python/TAL/TALGenerator.py:1.55.4.3	Tue Oct  8 17:45:54 2002
+++ Zope/lib/python/TAL/TALGenerator.py	Fri Jan  3 01:34:40 2003
@@ -162,7 +162,7 @@
                 if item[1] is None:
                     s = item[0]
                 else:
-                    s = '%s="%s"' % (item[0], cgi.escape(item[1], 1))
+                    s = '%s="%s"' % (item[0], TALDefs.attrEscape(item[1]))
                 attrlist[i] = item[0], s
                 new.append(" " + s)
         # if no non-optimizable attributes were found, convert to plain text


=== Zope/lib/python/TAL/TALParser.py 1.19.4.1 => 1.19.4.2 ===
--- Zope/lib/python/TAL/TALParser.py:1.19.4.1	Sat Sep 28 21:40:36 2002
+++ Zope/lib/python/TAL/TALParser.py	Fri Jan  3 01:34:40 2003
@@ -72,7 +72,7 @@
         for key, value in attrlist:
             key, keybase, keyns = self.fixname(key)
             ns = keyns or namens # default to tag namespace
-            item = key, value
+            item = key.lower(), value
             if ns == 'metal':
                 metaldict[keybase] = value
                 item = item + ("metal",)