Code reports error when given attribute names starting with dash
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
lxml |
New
|
Undecided
|
Unassigned |
Bug Description
When using `picosvg` on https:/
Minimal recreate code (after installing picosvg):
```py
from picosvg.svg import SVG
text_svg = SVG.fromstring("""
<svg xmlns="http://
<rect width="10" height="10"/>
<path d="M2,2 v6 h6 v-6 h-6 z" style="
</svg>
""")
print(text_
```
Traceback code:
```py
def parse_css_
style: str,
output: MutableMapping[str, Any],
property_names: Optional[
) -> str:
"""Parse CSS declaration list into {property: value} dict.
Args:
style: CSS declaration list without the enclosing braces,
as found in an SVG element's "style" attribute.
output: a dictionary where to store the parsed properties.
to be parsed; if not provided, all will be parsed.
Returns:
A string containing the unparsed style declarations, if any.
Raises:
ValueError if CSS declaration is invalid and can't be parsed.
References:
https:/
https:/
"""
unparsed = []
for declaration in style.split(";"):
if declaration.
if property_names is None or property_name in property_names:
else:
elif declaration.
raise ValueError(
return "; ".join(unparsed) + ";" if unparsed else ""
```
where `output` is given a dictionary of attributes:
```py
def _apply_styles(self, el: etree.Element):
parse_
```
Error:
```
Traceback (most recent call last):
File "d:\Desktop\
print(
File "D:\Desktop\
svg.
File "D:\Desktop\
self.
File "D:\Desktop\
self.
File "D:\Desktop\
parse_
File "D:\Desktop\
output[
File "src\lxml\
File "src\lxml\
File "src\lxml\
ValueError: Invalid attribute name '-inkscape-
```
description: | updated |
Related bug report and workaround: https:/ /github. com/googlefonts /picosvg/ pull/295