99import org .w3c .css .util .ApplContext ;
1010import org .w3c .css .util .CssVersion ;
1111import org .w3c .css .util .InvalidParamException ;
12+ import org .w3c .css .values .CssCheckableValue ;
1213import org .w3c .css .values .CssColor ;
1314import org .w3c .css .values .CssExpression ;
1415import org .w3c .css .values .CssIdent ;
1516import org .w3c .css .values .CssOperator ;
17+ import org .w3c .css .values .CssPercentage ;
1618import org .w3c .css .values .CssTypes ;
1719import org .w3c .css .values .CssValue ;
1820import org .w3c .css .values .CssValueList ;
1921
22+ import java .math .BigDecimal ;
2023import java .util .ArrayList ;
2124
2225import static org .w3c .css .values .CssOperator .COMMA ;
@@ -230,6 +233,18 @@ static public CssValue parseColorPercentageValue(ApplContext ac, CssExpression e
230233 op = exp .getOperator ();
231234 if (val .getType () == CssTypes .CSS_PERCENTAGE ) {
232235 gotPercentage = true ;
236+ CssCheckableValue v = val .getCheckableValue ();
237+ if (!v .isPositive ()) {
238+ throw new InvalidParamException ("value" , val .toString (), exp .toStringFromStart (), ac );
239+ }
240+ if (val .getRawType () == CssTypes .CSS_PERCENTAGE ) {
241+ CssPercentage p = val .getPercentage ();
242+ BigDecimal other = BigDecimal .valueOf (100 );
243+ if (p .getValue ().compareTo (other ) > 0 ) {
244+ throw new InvalidParamException ("lowerequal" ,
245+ exp .toStringFromStart (), other .toPlainString (), ac );
246+ }
247+ }
233248 values .add (val );
234249 } else {
235250 CssExpression e = new CssExpression ();
@@ -248,6 +263,19 @@ static public CssValue parseColorPercentageValue(ApplContext ac, CssExpression e
248263 if (gotPercentage ) {
249264 throw new InvalidParamException ("value" , val .toString (), caller , ac );
250265 }
266+ CssCheckableValue v = val .getCheckableValue ();
267+ if (!v .isPositive ()) {
268+ throw new InvalidParamException ("value" , val .toString (),
269+ exp .toStringFromStart (), ac );
270+ }
271+ if (val .getRawType () == CssTypes .CSS_PERCENTAGE ) {
272+ CssPercentage p = val .getPercentage ();
273+ BigDecimal other = BigDecimal .valueOf (100 );
274+ if (p .getValue ().compareTo (other ) > 0 ) {
275+ throw new InvalidParamException ("lowerequal" ,
276+ exp .toStringFromStart (), other .toPlainString (), ac );
277+ }
278+ }
251279 values .add (val );
252280 } else {
253281 if (!gotPercentage ) {
0 commit comments