From 9d84c091714f01e0088fab2202c10b505e78a607 Mon Sep 17 00:00:00 2001 From: joheriks Date: Mon, 28 Oct 2013 14:28:57 +0200 Subject: [PATCH] Parser stripped minus of negative numbers with unknown units (#12811) Change-Id: I8964b1732f867cb3c5aa5859d12e94a5978adece --- .../vaadin/sass/internal/parser/Parser.java | 148 +++++++++--------- .../com/vaadin/sass/internal/parser/Parser.jj | 3 +- .../automatic/css/negative-ch-value.css | 3 + .../automatic/scss/negative-ch-value.scss | 3 + 4 files changed, 85 insertions(+), 72 deletions(-) create mode 100644 theme-compiler/tests/resources/automatic/css/negative-ch-value.css create mode 100644 theme-compiler/tests/resources/automatic/scss/negative-ch-value.scss diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java index d7662d35a8..6989490648 100755 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java @@ -159,6 +159,7 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { /** * This method parses only one rule (style rule or at-rule, except + * * @charset). * * @param source @@ -5574,9 +5575,14 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { && (Character.isDigit(s.charAt(i)) || (s.charAt(i) == '.'))) { i++; } + /* + * result = LexicalUnitImpl.createDimen(n.beginLine, + * n.beginColumn, prev, Float.valueOf(s.substring(0, + * i)).floatValue(), s.substring(i)); + */ result = LexicalUnitImpl.createDimen(n.beginLine, - n.beginColumn, prev, Float.valueOf(s.substring(0, i)) - .floatValue(), s.substring(i)); + n.beginColumn, prev, number(op, n, s.length() - i), + s.substring(i)); break; case FUNCTION: result = function(op, prev); @@ -7110,15 +7116,15 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { return false; } - private boolean jj_3R_299() { - if (jj_scan_token(INTERPOLATION)) { + private boolean jj_3R_266() { + if (jj_3R_187()) { return true; } return false; } - private boolean jj_3R_266() { - if (jj_3R_187()) { + private boolean jj_3R_299() { + if (jj_scan_token(INTERPOLATION)) { return true; } return false; @@ -7138,6 +7144,28 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { return false; } + private boolean jj_3R_256() { + if (jj_scan_token(FUNCTION)) { + return true; + } + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { + jj_scanpos = xsp; + break; + } + } + xsp = jj_scanpos; + if (jj_3R_266()) { + jj_scanpos = xsp; + } + if (jj_scan_token(RPARAN)) { + return true; + } + return false; + } + private boolean jj_3R_263() { Token xsp; xsp = jj_scanpos; @@ -7187,8 +7215,8 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { return false; } - private boolean jj_3R_256() { - if (jj_scan_token(FUNCTION)) { + private boolean jj_3R_180() { + if (jj_scan_token(COMMA)) { return true; } Token xsp; @@ -7199,47 +7227,32 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { break; } } - xsp = jj_scanpos; - if (jj_3R_266()) { - jj_scanpos = xsp; - } - if (jj_scan_token(RPARAN)) { - return true; - } return false; } - private boolean jj_3R_180() { - if (jj_scan_token(COMMA)) { + private boolean jj_3R_247() { + if (jj_3R_260()) { return true; } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } return false; } - private boolean jj_3R_247() { - if (jj_3R_260()) { + private boolean jj_3R_246() { + if (jj_3R_259()) { return true; } return false; } - private boolean jj_3R_298() { - if (jj_scan_token(IDENT)) { + private boolean jj_3R_245() { + if (jj_3R_258()) { return true; } return false; } - private boolean jj_3R_246() { - if (jj_3R_259()) { + private boolean jj_3R_298() { + if (jj_scan_token(IDENT)) { return true; } return false; @@ -7257,13 +7270,6 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { return false; } - private boolean jj_3R_245() { - if (jj_3R_258()) { - return true; - } - return false; - } - private boolean jj_3R_297() { if (jj_3R_219()) { return true; @@ -7525,21 +7531,6 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { return false; } - private boolean jj_3R_196() { - if (jj_3R_220()) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_273()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - private boolean jj_3R_199() { Token xsp; xsp = jj_scanpos; @@ -7561,6 +7552,21 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { return false; } + private boolean jj_3R_196() { + if (jj_3R_220()) { + return true; + } + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_273()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + private boolean jj_3R_195() { if (jj_3R_219()) { return true; @@ -7899,6 +7905,13 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { return false; } + private boolean jj_3R_258() { + if (jj_scan_token(HASH)) { + return true; + } + return false; + } + private boolean jj_3_1() { if (jj_3R_176()) { return true; @@ -8013,13 +8026,6 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { return false; } - private boolean jj_3R_258() { - if (jj_scan_token(HASH)) { - return true; - } - return false; - } - private boolean jj_3_4() { if (jj_3R_179()) { return true; @@ -8027,15 +8033,15 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { return false; } - private boolean jj_3R_251() { - if (jj_3R_186()) { + private boolean jj_3R_259() { + if (jj_scan_token(URL)) { return true; } return false; } - private boolean jj_3R_259() { - if (jj_scan_token(URL)) { + private boolean jj_3R_251() { + if (jj_3R_186()) { return true; } return false; @@ -8088,6 +8094,13 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { return false; } + private boolean jj_3R_260() { + if (jj_scan_token(UNICODERANGE)) { + return true; + } + return false; + } + private boolean jj_3R_255() { Token xsp; xsp = jj_scanpos; @@ -8107,13 +8120,6 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { return false; } - private boolean jj_3R_260() { - if (jj_scan_token(UNICODERANGE)) { - return true; - } - return false; - } - private boolean jj_3_8() { Token xsp; xsp = jj_scanpos; diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj index 871be2c4d0..406030f7c9 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj @@ -2382,8 +2382,9 @@ LexicalUnitImpl nonVariableTerm(LexicalUnitImpl prev) : { LexicalUnitImpl result && (Character.isDigit(s.charAt(i)) || (s.charAt(i) == '.'))) { i++; } + result = LexicalUnitImpl.createDimen(n.beginLine, n.beginColumn, prev, - Float.valueOf(s.substring(0, i)).floatValue(), + number(op,n,s.length()-i), s.substring(i)); } | result=function(op, prev) ) ) diff --git a/theme-compiler/tests/resources/automatic/css/negative-ch-value.css b/theme-compiler/tests/resources/automatic/css/negative-ch-value.css new file mode 100644 index 0000000000..2cc75b2a6d --- /dev/null +++ b/theme-compiler/tests/resources/automatic/css/negative-ch-value.css @@ -0,0 +1,3 @@ +* { + top: -0.1ch; +} \ No newline at end of file diff --git a/theme-compiler/tests/resources/automatic/scss/negative-ch-value.scss b/theme-compiler/tests/resources/automatic/scss/negative-ch-value.scss new file mode 100644 index 0000000000..2cc75b2a6d --- /dev/null +++ b/theme-compiler/tests/resources/automatic/scss/negative-ch-value.scss @@ -0,0 +1,3 @@ +* { + top: -0.1ch; +} \ No newline at end of file -- 2.39.5