From e4637713395c1a4484e847edbbd93cd2d1d863d5 Mon Sep 17 00:00:00 2001 From: Mike Wiedenbauer Date: Tue, 18 Jan 2022 15:31:16 +0100 Subject: [PATCH 1/2] #82 fix rule to respect '.' in scientific notation --- ph-css/src/main/jjtree/ParserCSS30.jjt | 3 ++- .../test/resources/testfiles/css30/good/issue79.css | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ph-css/src/main/jjtree/ParserCSS30.jjt b/ph-css/src/main/jjtree/ParserCSS30.jjt index ab6e9ea0..14bb1a04 100644 --- a/ph-css/src/main/jjtree/ParserCSS30.jjt +++ b/ph-css/src/main/jjtree/ParserCSS30.jjt @@ -174,7 +174,8 @@ TOKEN : | < #NAME: ( )+ > | < #NUM: ( ["0"-"9"] )+ | ( ["0"-"9"] )* "." ( ["0"-"9"] )+ - | ( ["0"-"9"] )+ ["e", "E"] ( ["+", "-"] )? ( ["0"-"9"] )+ > + | ( ["0"-"9"] )+ ["e", "E"] ( ["+", "-"] )? ( ["0"-"9"] )+ + | ( ["0"-"9"] )+ "." ( ["0"-"9"] )+ ["e", "E"] ( ["+", "-"] )? ( ["0"-"9"] )+ > | < #URLCHAR: ["!","#","$","%","&","*"-"[","]"-"~"] | | > diff --git a/ph-css/src/test/resources/testfiles/css30/good/issue79.css b/ph-css/src/test/resources/testfiles/css30/good/issue79.css index f0071afa..57ec44cc 100644 --- a/ph-css/src/test/resources/testfiles/css30/good/issue79.css +++ b/ph-css/src/test/resources/testfiles/css30/good/issue79.css @@ -9,6 +9,11 @@ div { padding: 999e-06; padding: 999e+6; padding: 999e+06; + padding: 1.5e6; + padding: 1.5e-6; + padding: 1.5e-06; + padding: 1.5e+6; + padding: 1.5e+06; } span { @@ -22,4 +27,9 @@ span { padding: 999e-06em; padding: 999e+6em; padding: 999e+06em; + padding: 1.5e6em; + padding: 1.5e-6em; + padding: 1.5e-06em; + padding: 1.5e+6em; + padding: 1.5e+06em; } From 72d6b04f26ba1bf197837b7472e2fa67741da568 Mon Sep 17 00:00:00 2001 From: Mike Wiedenbauer Date: Tue, 18 Jan 2022 16:09:43 +0100 Subject: [PATCH 2/2] #82 also respect regex in parser helper --- .../src/main/java/com/helger/css/parser/CSSParseHelper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ph-css/src/main/java/com/helger/css/parser/CSSParseHelper.java b/ph-css/src/main/java/com/helger/css/parser/CSSParseHelper.java index 5a46e0b3..79013ab5 100644 --- a/ph-css/src/main/java/com/helger/css/parser/CSSParseHelper.java +++ b/ph-css/src/main/java/com/helger/css/parser/CSSParseHelper.java @@ -43,10 +43,10 @@ public final class CSSParseHelper /** * Order of the rules in brackets is important!
- * The part "([eE][+-]?[0-9]+)?" was added for #79 + * The parts "([eE][+-]?[0-9]+)?" were added for #79, #82 */ @RegEx - private static final String SPLIT_NUMBER_REGEX = "^([0-9]*\\.[0-9]+|[0-9]+([eE][+-]?[0-9]+)?).*$"; + private static final String SPLIT_NUMBER_REGEX = "^([0-9]*\\.[0-9]+([eE][+-]?[0-9]+)?|[0-9]+([eE][+-]?[0-9]+)?).*$"; private static final Pattern SPLIT_NUMBER_PATTERN = RegExCache.getPattern (SPLIT_NUMBER_REGEX); @PresentForCodeCoverage