This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 19011 - Wrong validation of length 0.0 - use value.compareTo(BigDecimal.ZERO)==0 instead of value.equals(BigDecimal.ZERO) - [WITH PATCH]
Summary: Wrong validation of length 0.0 - use value.compareTo(BigDecimal.ZERO)==0 inst...
Status: RESOLVED FIXED
Alias: None
Product: CSSValidator
Classification: Unclassified
Component: Parser (show other bugs)
Version: CSS Validator
Hardware: All All
: P2 major
Target Milestone: ---
Assignee: This bug has no owner yet - up for the taking
QA Contact: qa-dev tracking
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-25 17:57 UTC by Hannes Erven
Modified: 2012-09-28 18:38 UTC (History)
0 users

See Also:


Attachments
Suggested patch (3.60 KB, text/plain)
2012-09-25 17:57 UTC, Hannes Erven
Details

Description Hannes Erven 2012-09-25 17:57:27 UTC
Created attachment 1190 [details]
Suggested patch

When specifying lengths, CSS allows zero lengths to be specified without a unit. This works fine for "0", but not for "0.0" .
The specification clearly states that any numbers may contain a decimal point, so I think that should work.

To reproduce, try this:
* {margin: 0.0}


The reason for this behaviour is what I think is an inappropriate use of the BigDecimal's "equals" method. As the javadoc states, the method returns only true when the value and scale for both arguments are identical. This means that 2.0 does not equal 2.00 or for the example above, 0 == BigDecimal.ZERO but 0.0 does not.

I'll attach a patch with all those places corrected that I think need to be reworked.
There are still some (few) lines where there are still == checks, but where I was not sure what behaviour was actually intended.
Comment 1 Hannes Erven 2012-09-25 17:59:09 UTC
(corrected misleading title. sorry.)
Comment 2 Yves Lafon 2012-09-28 18:38:33 UTC
It is indeed an issue, thanks for finding it and for providing a patch!
I expanded it a bit to cover Resolution and other improper use of equals.