GNOME Bugzilla – Bug 695162
Style element ignored if no type attribute is specified
Last modified: 2017-12-13 17:58:55 UTC
I just noticed that if I remove type="text/css" from a style element in an SVG file, eog fails to apply the styles it contains. This doesn't seem to comply with the SVG spec at http://www.w3.org/TR/SVG/styling.html#StyleElementTypeAttribute: "If a ‘type’ is not provided, the value of ‘contentStyleType’ on the ‘svg’ element shall be used, which in turn defaults to "text/css" [RFC2046]."
Created attachment 238058 [details] Styles are ignored in librsvg 2.36.4 / eog 3.6.2. Adding type="text/css" to the style element fixes it.
I have also noticed this problem. I had been using <style> with no type specified, and was having to workaround this bug by changing styling to use inline attributes. It's good to know that the lack of type="text/css" was the problem, and I hope this bug gets fixed soon.
*** Bug 738627 has been marked as a duplicate of this bug. ***
Back reference: https://phabricator.wikimedia.org/T68672
Created attachment 316798 [details] [review] Better follow the W3C spec regarding <style> elements The SVG 1.1 Recommendation published by the World Wide Web Consortium at http://www.w3.org/TR/SVG/styling.html#StyleElementTypeAttribute prescribes: If a ‘type’ is not provided, the value of ‘contentStyleType’ on the ‘svg’ element shall be used, which in turn defaults to "text/css" Instead, librsvg completely ignores any <style> element without the ‘type’ attribute explicitly set to "text/css". This patch adds a content_style_type property to RsvgNodeSvg set to the value of its ‘contentStyleType’ attribute, or "text/css". The ‘type’ attribute of every <style> will fall back to the content_style_type of the root <svg>.
I don't yet understand whether all <svg>s should support ‘contentStyleType’, or the root one only. By the way, I have some test images to update the patch with if you tell me where to put them. Thanks in advance.
(In reply to Ricordisamoa from comment #6) > By the way, I have some test images to update the patch with if you tell me > where to put them. Thanks in advance. If they are less than 3 MB and free content you could upload them here as an attachment, or just provide links to them?
(In reply to André Klapper from comment #7) > (In reply to Ricordisamoa from comment #6) > > By the way, I have some test images to update the patch with if you tell me > > where to put them. Thanks in advance. > > If they are less than 3 MB and free content you could upload them here as an > attachment, or just provide links to them? @Ricoridamoa You may also add them to subfolder ./tests/bugs of your patch. Take existing files as examples. Execute "make test" to execute a test and check for integration into test schema.
Created attachment 317008 [details] [review] Better follow the W3C spec regarding <style> elements The SVG 1.1 Recommendation published by the World Wide Web Consortium at http://www.w3.org/TR/SVG/styling.html#StyleElementTypeAttribute prescribes: If a ‘type’ is not provided, the value of ‘contentStyleType’ on the ‘svg’ element shall be used, which in turn defaults to "text/css" Instead, librsvg completely ignores any <style> element without the ‘type’ attribute explicitly set to "text/css". This patch adds a content_style_type property to RsvgNodeSvg set to the value of its ‘contentStyleType’ attribute, or "text/css". The ‘type’ attribute of every <style> will fall back to the content_style_type of the root <svg>.
I don't think I got them in the right location...
Please also check for unwanted performance regressions / memory leaks.
*** Bug 738118 has been marked as a duplicate of this bug. ***
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/librsvg/issues/74.