static var PercentPattern = new RegExp("^\\s*(1?\\d?\\d?\\.?\\d*)\\s*%\\s*$");
static var NumberPattern = new RegExp("^\\s*(\\d{0,3}\\.?\\d*)\\s*$");

These patterns actually accept any number, because of the \\d*. And the percent pattern also accept this string ".%" or simply "%".

Percent pattern: ^\\s*(100(?:\\.0*)?|\\d{1,2}(?:\\.\\d*)?|\\.\\d+)\\s*%\\s*$
1) "100", possibly followed by "." and any number of "0".
2) Any number in range [0,99], possibly followed by "." and any number of "0". (This part allows leading "0", is that ok? For example "01%")
3) Or numbers without leading digits as in ".5%"

A similar for the number pattern: ^\\s*(\\d{1,3}(?:\\.\\d*)?|\\.\\d+)\\s*$

On 11/16/2010 2:54 PM, P T Withington wrote:
[Checking in ahead of review so Fred can test it.]

Change ptw-20101116-sAN by [email protected] on 2010-11-16 08:45:41 EST
     in /Users/ptw/OpenLaszlo/trunk-devo
     for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Liberate CSS colorspec parser

Bugs Fixed:  LPP-9528 LzColorUtils does not handle rbga(n,n,n,0) correctly

Technical Reviewer: [email protected] (pending)
QA Reviewer: [email protected] (pending)

Details:
     lzunit-lzutils: Add some tests, including failing case Fred
     reported.  Adjust hsv test to be accurate.  Test that all named
     colors and a random sampling of internal representations can be
     correctly unconverted and reconverted by the CSS parser and get
     back the same value.

     LzUtils: Round input values to internalfromrgba for more accurate
     results.  Which means internalfrom(hsvhsl)a no longer needs to
     (incorrectly) floor their values before calling internalfromrgba.
     Fix the RegExp patterns used by internalfromccc to allow decimals
     with no preceding digit.  Fudge the return type to permit
     transparent->null (bug filed, to replace with internal
     representation of rgba(0,0,0,0)).

Tests:
     lzunit-lzutils

Files:
M       test/lfc/lzunit-lzutils.lzx
M       WEB-INF/lps/lfc/services/LzUtils.lzs

Changeset: http://svn.openlaszlo.org/openlaszlo/patches/ptw-20101116-sAN.tar

Reply via email to