Handle extra whitespace in svg element's style value (#1170)

This commit is contained in:
Mark Miller 2021-03-27 14:26:24 -07:00 committed by GitHub
commit b460712878
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -72,13 +72,13 @@ def cascade_element_style(
try:
key, value = style_spec.split(":")
except ValueError as e:
if not style_spec:
if not style_spec.strip():
# there was just a stray semicolon at the end, producing an emptystring
pass
else:
raise e
else:
style[key] = value
style[key.strip()] = value.strip()
return style

View file

@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
<g>
<path style="fill:white" d="m 50,50 10,10 -10,10 z m 30,0 -10,-10, -10,10 z">
<path style="fill : white" d="m 50,50 10,10 -10,10 z m 30,0 -10,-10, -10,10 z">
</path>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 175 B

After

Width:  |  Height:  |  Size: 177 B

Before After
Before After