Comment 7 for bug 714731

Revision history for this message
Jan Thor (jan-janthor) wrote :

I added a patch for revision 201 of scour.py.

I restricted the list of attributes to SVG 1.1 presentation attributes and SVG 1.2 tiny properties; the other attributes are different for different elements, so the right thing to do would have been a dictionary of dictionaries, with tagnames mapping to dictionaries mapoping attribute names to default values, and that sounds like a lot of work for little gain. Otherwise, I could try to rely on certain attributes only making sense only for certain tags (like the attribute 'k1' only appearing in a certain filter), but that assumption might break on later revisions of SVG.

I also excluded those attributes with a default value of 'auto', since I think it's rare that an editor (or a human author) will include those.

My patch also interacts with removeUnusedAttributesOnParent(), but, as far as I can see, only in a harmless way.

I removed some checks for default values which became obsolete (removing two TODO's doing that), and I also made changes to the canonicalization of colors and floats to apply them to styles.

I implemented the list of 'tainted' attributes as a set; sets have been introduced in Python 2.4, but as far as I'm aware, Scour doesn't maintain backwards compatibility further back, so that should be okay, I hope.

I did break a test in testscour.py; more on that in the next comment.