Simplestyle extension helper breaks on spaces in styles (with fix)

Bug #837603 reported by nikitakit
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
Low
nikitakit

Bug Description

Simplestyle doesn't work with styles that contain spaces after the colon, e.g. "stop-color: rgb(0,0,0);" (note space after ':') The resulting style will have a color value that begins with a space, which can't be parsed by parseColor.

Proposed fix: strip spaces surrounding style keys and values.
For example, replace [share/extensions/simplestyle.py:: line 179]:
return dict([i.split(":") for i in s.split(";") if len(i)])
with:
return dict([[x.strip() for x in i.split(":")] for i in s.split(";") if len(i)])

jazzynico (jazzynico)
tags: added: extensions-plugins styles
jazzynico (jazzynico)
Changed in inkscape:
assignee: nobody → JazzyNico (jazzynico)
importance: Undecided → Low
milestone: none → 0.49
status: New → In Progress
Revision history for this message
jazzynico (jazzynico) wrote :

Fix committed in the trunk, revision 10610.
Thanks for the patch!

Changed in inkscape:
assignee: JazzyNico (jazzynico) → nikitakit (nikitakit)
status: In Progress → Fix Committed
jazzynico (jazzynico)
tags: added: backport-proposed
tags: added: color
Revision history for this message
nikitakit (nikitakit) wrote :

Thanks for committing.

Of course, there are still edge cases falling through the cracks: namely a final space at the end of the style. It could be fixed by changing len(i) to len(i.strip()) or changing s.split(";") to s.strip().split(";")

It might be worth considering writing an actual parser instead of a one-liner.

Revision history for this message
jazzynico (jazzynico) wrote :

Back-ported to the 0.48.x branch, revision 9830.

tags: removed: backport-proposed
Changed in inkscape:
milestone: 0.49 → 0.48.3
Ted Gould (ted)
Changed in inkscape:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.