From 968f65b8f614e9545c3bca36158a83cc02675c96 Mon Sep 17 00:00:00 2001 From: Dave Wichers Date: Mon, 8 Jan 2024 11:23:03 -0500 Subject: [PATCH] Apply formatting changes to two source files and add -SNAPSHOT to htmlunit import. --- pom.xml | 2 +- .../org/owasp/validator/css/CssParser.java | 107 +++++++++--------- .../validator/html/scan/MagicSAXFilter.java | 3 +- 3 files changed, 57 insertions(+), 55 deletions(-) diff --git a/pom.xml b/pom.xml index 767c236..ec12cd7 100644 --- a/pom.xml +++ b/pom.xml @@ -94,7 +94,7 @@ org.htmlunit neko-htmlunit - 3.10.0 + 3.10.0-SNAPSHOT org.apache.httpcomponents.client5 diff --git a/src/main/java/org/owasp/validator/css/CssParser.java b/src/main/java/org/owasp/validator/css/CssParser.java index 2ae2f63..832f6c9 100644 --- a/src/main/java/org/owasp/validator/css/CssParser.java +++ b/src/main/java/org/owasp/validator/css/CssParser.java @@ -35,64 +35,65 @@ public class CssParser extends org.apache.batik.css.parser.Parser { - /** - * This implementation is a workaround to solve leading dash errors on property names. - * @see https://issues.apache.org/jira/browse/BATIK-1112 - * @param inSheet Specifies if the style to parse is inside a sheet or the sheet itself. - * @throws CSSException Thrown if there are parsing errors in CSS - */ - @Override - protected void parseStyleDeclaration(final boolean inSheet) throws CSSException { - boolean leadingDash = false; - for (;;) { - switch (current) { - case LexicalUnits.EOF: - if (inSheet) { - throw createCSSParseException("eof"); - } - return; - case LexicalUnits.RIGHT_CURLY_BRACE: - if (!inSheet) { - throw createCSSParseException("eof.expected"); - } - nextIgnoreSpaces(); - return; - case LexicalUnits.SEMI_COLON: - nextIgnoreSpaces(); - continue; - case LexicalUnits.MINUS: - leadingDash = true; - next(); - break; - default: - throw createCSSParseException("identifier"); - case LexicalUnits.IDENTIFIER: - } + /** + * This implementation is a workaround to solve leading dash errors on property names. + * + * @see https://issues.apache.org/jira/browse/BATIK-1112 + * @param inSheet Specifies if the style to parse is inside a sheet or the sheet itself. + * @throws CSSException Thrown if there are parsing errors in CSS + */ + @Override + protected void parseStyleDeclaration(final boolean inSheet) throws CSSException { + boolean leadingDash = false; + for (; ; ) { + switch (current) { + case LexicalUnits.EOF: + if (inSheet) { + throw createCSSParseException("eof"); + } + return; + case LexicalUnits.RIGHT_CURLY_BRACE: + if (!inSheet) { + throw createCSSParseException("eof.expected"); + } + nextIgnoreSpaces(); + return; + case LexicalUnits.SEMI_COLON: + nextIgnoreSpaces(); + continue; + case LexicalUnits.MINUS: + leadingDash = true; + next(); + break; + default: + throw createCSSParseException("identifier"); + case LexicalUnits.IDENTIFIER: + } - final String name = (leadingDash ? "-" : "") + scanner.getStringValue(); - leadingDash = false; + final String name = (leadingDash ? "-" : "") + scanner.getStringValue(); + leadingDash = false; - if (nextIgnoreSpaces() != LexicalUnits.COLON) { - throw createCSSParseException("colon"); - } - nextIgnoreSpaces(); + if (nextIgnoreSpaces() != LexicalUnits.COLON) { + throw createCSSParseException("colon"); + } + nextIgnoreSpaces(); - LexicalUnit exp = null; + LexicalUnit exp = null; - try { - exp = parseExpression(false); - } catch (final CSSParseException e) { - reportError(e); - } + try { + exp = parseExpression(false); + } catch (final CSSParseException e) { + reportError(e); + } - if (exp != null) { - boolean important = false; - if (current == LexicalUnits.IMPORTANT_SYMBOL) { - important = true; - nextIgnoreSpaces(); - } - documentHandler.property(name, exp, important); - } + if (exp != null) { + boolean important = false; + if (current == LexicalUnits.IMPORTANT_SYMBOL) { + important = true; + nextIgnoreSpaces(); } + documentHandler.property(name, exp, important); + } } + } } diff --git a/src/main/java/org/owasp/validator/html/scan/MagicSAXFilter.java b/src/main/java/org/owasp/validator/html/scan/MagicSAXFilter.java index 2b3a115..5fe4660 100644 --- a/src/main/java/org/owasp/validator/html/scan/MagicSAXFilter.java +++ b/src/main/java/org/owasp/validator/html/scan/MagicSAXFilter.java @@ -322,7 +322,8 @@ public void startElement(QName element, XMLAttributes attributes, Augmentations if ("style".equalsIgnoreCase(name)) { CssScanner styleScanner = makeCssScanner(); try { - CleanResults cr = styleScanner.scanInlineStyle(value, element.getLocalpart(), maxInputSize); + CleanResults cr = + styleScanner.scanInlineStyle(value, element.getLocalpart(), maxInputSize); attributes.setValue(i, cr.getCleanHTML()); validattributes.addAttribute(makeSimpleQname(name), "CDATA", cr.getCleanHTML()); errorMessages.addAll(cr.getErrorMessages());