Bug 181170 - leading whitespace in numerical SVG attribute is interpreted as 0
Summary: leading whitespace in numerical SVG attribute is interpreted as 0
Status: RESOLVED UNMAINTAINED
Alias: None
Product: ksvg
Classification: Unmaintained
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Nikolas Zimmermann
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-18 13:26 UTC by esigra
Modified: 2011-10-17 21:12 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description esigra 2009-01-18 13:26:23 UTC
Version:           3.5.10 (using KDE 3.5.10)
OS:                Linux
Installed from:    Gentoo Packages

See this example file:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="128" height="128" version="1.1" xmlns="http://www.w3.org/2000/svg">
	<line x1= "64" y1="8" x2=" 64" y2="120" style="stroke:rgb(0,0,0)"/>
</svg>

Not that the attribute x2 has the string value " 64" which is interpreted as 0 numerically by KSVG. The document is valid according to the W3C validator and it is interpreted correctly by Inkscape. Even OpenOffice does not have this problem. Whitespace should be skipped automatically when reading numbers (see for example man:strtoll).
Comment 1 esigra 2011-02-05 09:58:51 UTC
The behaviour is the same with KDE 4.5.5. Mozilla has the same issue; [https://bugzilla.mozilla.org/show_bug.cgi?id=404089]. Inkscape and OpenOffice still ignore the whitespace and interpret the number that follows correctly. The file is still valid SVG 1.1 according to the W3C validator.
Comment 2 longsonr 2011-02-05 11:33:05 UTC
The w3c validator is wrong. 

The SVG spec doesn't *allow* any whitespace in these fields

<http://www.w3.org/TR/SVG/svgdtd.html>:
    x1 %Coordinate.datatype; #IMPLIED

<http://www.w3.org/TR/SVG/types.html>:
"A <coordinate> represents a <length>..."
"The format of a <length> is a <number>  optionally followed immediately by a
unit identifier."
And the <number> definition says which characters are allowed and those don't include any whitespace characters.
Comment 3 Christoph Feck 2011-10-17 21:07:06 UTC
This component has been replaced with the QtSvg based "svgpart" in KDE 4. If
this issue still needs to be addressed, please add a comment.