paraparser.py: improved checking on <a> tag attributes
authorrgbecker
Fri, 23 Nov 2007 18:23:31 +0000
changeset 2893 7432e06445ba
parent 2892 131b417f9845
child 2894 78cd38a39719
paraparser.py: improved checking on <a> tag attributes
reportlab/platypus/paraparser.py
--- a/reportlab/platypus/paraparser.py	Mon Nov 19 13:03:54 2007 +0000
+++ b/reportlab/platypus/paraparser.py	Fri Nov 23 18:23:31 2007 +0000
@@ -470,15 +470,21 @@
     #### anchor
     def start_a(self, attributes):
         A = self.getAttributes(attributes,_anchorAttrMap)
-        if A.get('name',None):
+        name = A.get('name',None)
+        if name is not None:
+            name = name.strip()
+            if not name:
+                self._syntax_error('<a name="..."/> anchor variant requires non-blank name')
             if len(A)>1:
                 self._syntax_error('<a name="..."/> anchor variant only allows name attribute')
                 A = dict(name=A['name'])
             A['_selfClosingTag'] = 'anchor'
-        elif not A.get('href',None):
-            self._syntax_error('<a> tag must have name or href attribute')
         else:
-            A['link'] = A.pop('href')   #convert to our link form
+            href = A.get('href','').strip()
+            if not href:
+                self._syntax_error('<a> tag must have non-blank name or href attribute')
+            A['link'] = href    #convert to our link form
+            A.pop('href')
         self._push(**A)
 
     def end_a(self):