WebHelpers2 icon indicating copy to clipboard operation
WebHelpers2 copied to clipboard

HTML tag c arg escaping content

Open guruofgentoo opened this issue 7 years ago • 1 comments

My understanding is that literal strings should not be escaped at any point. However: HTML.li(c=link_to('something', '#')) yields literal('<li>&lt;a href=&#34;#&#34;&gt;something&lt;/a&gt;</li>') in Python 3 (3.6 to be specific).

The same input in Python 2.7 gives the expected literal(u'<li><a href="#">something</a></li>'). Also, in Python 3, passing the content without the c kwarg HTML.li(link_to('something', '#')) gives the expected literal('<li><a href="#">something</a></li>').

guruofgentoo avatar Jun 15 '17 13:06 guruofgentoo

Literals should never be escaped, and c should behave exactly as *args. Write a unit test for the example above. It will presumably fail on Python 3 due to a difference in c processing. builder.py lines 240-241 (commit ed4a43) appear to convert c to args so they're exactly the same, but there may be a subtle difference.

The purpose of c is to put the tag content after the tag attributes, which is the opposite of Python's positional-argument syntax. It was not anticipated that c would be used without keyword attributes, or that the value of c would be literal(s), nevertheless it should handle them properly.

mikeorr avatar Dec 31 '18 01:12 mikeorr