SVG elements cannot have spaces before attribute values

RESOLVED DUPLICATE of bug 404089

Status

()

Firefox
General
RESOLVED DUPLICATE of bug 404089
10 years ago
10 years ago

People

(Reporter: Cyberknight Massao Kawata, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

10 years ago
User-Agent:       Opera/9.52 (Windows NT 5.1; U; en)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9) Gecko/2008052906 Firefox/3.0

The elements of an SVG image cannot have spaces before the values of their attributes, or else Firefox will completely ignore them. For example, it renders the elements correctly for cx="100px", but will simply ignore a cx="  100px" attribute. The problem occurs with all elements ("circle", "rect" etc.), with any numeric attribute, but not with alphanumeric attributes (like "style", for example, which parses correctly the values).

Reproducible: Always

Steps to Reproduce:
1. Create an SVG file with some elements, e.g., three circles:

<svg  xmlns="http://www.w3.org/2000/svg"><g>
  <circle cx="100" cy="100" r="50" style="fill:red"/>
  <circle cx="150" cy="150" r="50" style="fill:green"/>
  <circle cx="200" cy="200" r="50" style="fill:blue"/>
</g></svg>

Opening the file in Firefox will render three circles, aligned correctly.

2. Now add one space before, say, the green circle's cx attribute's value and save the SVG file:

<svg  xmlns="http://www.w3.org/2000/svg"><g>
  <circle cx="100" cy="100" r="50" style="fill:red"/>
  <circle cx=" 150" cy="150" r="50" style="fill:green"/>
  <circle cx="200" cy="200" r="50" style="fill:blue"/>
</g></svg>

3. Reload the image. The red and the blue circles are still on the same places, but the green one is set at (0,150), that is, the cx attribute is assumed as zero (or, otherwise, it is ignored, so the default zero is used).
Actual Results:  
All SVG files with spaces before any numeric attribute are incorrectly rendered. When people edit SVG files by hand, it's natural to add spaces to tabulate a series of similar or correlated elements or even by mistake, like this:

...
  <rect x="100" y="100" width="1000" height="50" style="fill:blue"/>
  <rect x="100" y="100" width=" 100" height="50" style="fill:green"/>
  <rect x="100" y="100" width="  10" height="50" style="fill:red"/>
...

Sooner or later, people will stumble on an SVG image with a space before an attribute and it will render oddly on Firefox...

Expected Results:  
Firefox should completely ignore spaces before numeric values passed to attributes of SVG elements.

Opera renders SVG with spaces before numeric values correctly. It took me some time to realize that it was a bug in Firefox, not a problem with my hand-written SVG files.
This is invalid. Spaces are not allowed per the specification. 

I guess you should raise a bug on Opera since it is not doing the right thing.

Status: UNCONFIRMED → RESOLVED
Last Resolved: 10 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 404089
You need to log in before you can comment on or make changes to this bug.