Skip to content

Commit

Permalink
fixes #629
Browse files Browse the repository at this point in the history
  • Loading branch information
jph00 committed Sep 23, 2024
1 parent cb407c9 commit 88bef19
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion fastcore/xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def _to_xml(elm, lvl=0, indent=True, do_escape=True):
stag = tag
if attrs:
sattrs = ' '.join(_to_attr(k, v) for k, v in attrs.items() if v not in (False, None, ''))
stag += f' {sattrs}' if sattrs else stag
if sattrs: stag += f' {sattrs}'

cltag = '' if is_void else f'</{tag}>'

Expand Down
5 changes: 3 additions & 2 deletions nbs/11_xml.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@
" stag = tag\n",
" if attrs:\n",
" sattrs = ' '.join(_to_attr(k, v) for k, v in attrs.items() if v not in (False, None, ''))\n",
" stag += f' {sattrs}' if sattrs else stag\n",
" if sattrs: stag += f' {sattrs}'\n",
"\n",
" cltag = '' if is_void else f'</{tag}>'\n",
"\n",
Expand Down Expand Up @@ -508,7 +508,8 @@
"test_eq(to_xml(Div(\"<script>alert('XSS')</script>\"), do_escape=True),\n",
" '<div>&lt;script&gt;alert(&#x27;XSS&#x27;)&lt;/script&gt;</div>\\n')\n",
"test_eq(to_xml(Div(\"<script>alert('XSS')</script>\"), do_escape=False),\n",
" \"<div><script>alert('XSS')</script></div>\\n\")"
" \"<div><script>alert('XSS')</script></div>\\n\")\n",
"test_eq(to_xml(Div(foo=False), indent=False), '<div></div>')"
]
},
{
Expand Down

0 comments on commit 88bef19

Please sign in to comment.