fix href bug reported by bitbucket.kmouts py33
authorrobin
Thu, 10 Oct 2013 15:06:34 +0100
branchpy33
changeset 3931 ceee76b69e7c
parent 3930 950841932d03
child 3932 a26ea864c24a
fix href bug reported by bitbucket.kmouts
src/reportlab/platypus/paraparser.py
tests/test_platypus_paragraphs.py
--- a/src/reportlab/platypus/paraparser.py	Sat Dec 07 18:04:12 2013 +0000
+++ b/src/reportlab/platypus/paraparser.py	Thu Oct 10 15:06:34 2013 +0100
@@ -664,10 +664,8 @@
             A['_selfClosingTag'] = 'anchor'
         else:
             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')
+            A.pop('href',None)
         self._push(**A)
 
     def end_a(self):
@@ -1005,7 +1003,7 @@
                 j = attrMap[k]
                 func = j[1]
                 try:
-                    A[j[0]] = (func is None) and v or func(v)
+                    A[j[0]] = v if func is None else func(v)
                 except:
                     self._syntax_error('%s: invalid value %s'%(k,v))
             else:
--- a/tests/test_platypus_paragraphs.py	Sat Dec 07 18:04:12 2013 +0000
+++ b/tests/test_platypus_paragraphs.py	Thu Oct 10 15:06:34 2013 +0100
@@ -199,7 +199,7 @@
 u with a dieresis on top &lt;unichar code=0xfc/&gt;="<unichar code="0xfc"/>" and this &amp;#xfc;="&#xfc;" and this \\xc3\\xbc="\xc3\xbc". On the other hand this
 should be a pound sign &amp;pound;="&pound;" and this an alpha &amp;alpha;="&alpha;". You can have links in the page <link href="http://www.reportlab.com" color="blue">ReportLab</link> &amp; <a href="http://www.reportlab.org" color="green">ReportLab.org</a>.
 Use scheme "pdf:" to indicate an external PDF link, "http:", "https:" to indicate an external link eg something to open in
-your browser. If an internal link begins with something that looks like a scheme, precede with "document:". <strike>This text should have a strike through it.</strike>
+your browser. If an internal link begins with something that looks like a scheme, precede with "document:". Empty hrefs should be allowed ie <a href="">&lt;a href=""&gt;test&lt;/a&gt;</a> should be allowed. <strike>This text should have a strike through it.</strike>
 '''
         from reportlab.platypus.flowables import ImageAndFlowables, Image
         from reportlab.lib.testutils import testsFolder