Page MenuHomePhabricator

MediaWiki doesn't handle SVG dimensions of decimal points with no preceding digits
Closed, ResolvedPublic

Description

https://commons.wikimedia.org/wiki/File:DFO_Logo.svg was parsed incorrectly by MediaWiki because its height was specified as a decimal without a leading zero and in non-pixel units. .417118in is a valid height value in SVG per W3C validator and works in librsvg 2.40.18, Inkscape, Firefox, and Chromium.

Event Timeline

Hello71 created this task.

@Aklapper I assume @Hello71 is referring to the first version of the file, where the height is specified as .417118in (that first version doesn't render). The current file's height is 1.0594797cm. I think librsvg might have some issues with handling decimal points with no leading zeroes, as I've run into similar issues with the stroke-dasharray attribute.

Jc86035 renamed this task from SVG shows zero height and renders generic placeholder to librsvg doesn't handle decimal points with no preceding digits.Aug 6 2018, 8:40 AM

@Aklapper I've reuploaded the original file with the only difference being that the file height is now 0.417118in. The file now works.

Jc86035 changed the task status from Stalled to Open.Aug 6 2018, 8:44 AM
Jc86035 updated the task description. (Show Details)

Ah, I am sorry! I missed the revision info in the task description.

@Jc86035 It could also be an issue with the SVG metadata parser of MediaWiki.

This looks suspicious: https://gerrit.wikimedia.org/g/mediawiki/core/+/master/includes/media/SVGMetadataExtractor.php#383
though the fallback i guess would create incorrect data, not so much cause missing data perhaps...

Phab copied it from the parent ticket.

@Jc86035 It could also be an issue with the SVG metadata parser of MediaWiki.

This looks suspicious: https://gerrit.wikimedia.org/g/mediawiki/core/+/master/includes/media/SVGMetadataExtractor.php#383
though the fallback i guess would create incorrect data, not so much cause missing data perhaps...

Well in this case, the value is .417118in, so it will be entered as .417118px, which is presumably rounded to 0 somewhere else.

I uploaded https://commons.wikimedia.org/wiki/File:DFO_Logo_2x_size_test.svg with a height of .834236in to test, and it does in fact display a height of 1 pixel and also render a one pixel tall preview.

Hello71 renamed this task from librsvg doesn't handle decimal points with no preceding digits to MediaWiki doesn't handle SVG dimensions of decimal points with no preceding digits.Aug 6 2018, 12:41 PM
Hello71 updated the task description. (Show Details)
TheDJ triaged this task as Low priority.Aug 6 2018, 3:01 PM
TheDJ added a project: good first task.

@Hello71 Thank you for confirming. Should be an easy fix then.

So the official SVG spec indicates it should be something more in the order of:
/^\s*([-+]?\d*(?:\.\d+|\d+)(?:[Ee][-+]?\d+)?)\s*(em|ex|px|pt|pc|cm|mm|in|%|)\s*$/

https://www.w3.org/TR/SVG/types.html#DataTypeLength
https://www.w3.org/TR/SVG/types.html#DataTypeNumber

Change 451092 had a related patch set uploaded (by TheDJ; owner: TheDJ):
[mediawiki/core@master] SVG: SVG unit parser support for wider range of number

https://gerrit.wikimedia.org/r/451092

Change 451092 merged by jenkins-bot:
[mediawiki/core@master] SVG: SVG unit parser support for wider range of number

https://gerrit.wikimedia.org/r/451092

TheDJ claimed this task.
TheDJ removed a project: Patch-For-Review.