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

Bug #837603 reported by nikitakit on 2011-08-30
This bug affects 1 person
Affects Status Importance Assigned to Milestone

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/ line 179]:
return dict([i.split(":") for i in s.split(";") if len(i)])
return dict([[x.strip() for x in i.split(":")] for i in s.split(";") if len(i)])

jazzynico (jazzynico) on 2011-08-30
tags: added: extensions-plugins styles
jazzynico (jazzynico) on 2011-09-01
Changed in inkscape:
assignee: nobody → JazzyNico (jazzynico)
importance: Undecided → Low
milestone: none → 0.49
status: New → In Progress
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) on 2011-09-01
tags: added: backport-proposed
tags: added: color
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.

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) on 2012-02-15
Changed in inkscape:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers