Skip to content

Commit

Permalink
Apply formatting changes to two source files and add -SNAPSHOT to htm…
Browse files Browse the repository at this point in the history
…lunit import.
  • Loading branch information
davewichers committed Jan 8, 2024
1 parent 996bce2 commit 968f65b
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 55 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<dependency>
<groupId>org.htmlunit</groupId>
<artifactId>neko-htmlunit</artifactId>
<version>3.10.0</version>
<version>3.10.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
Expand Down
107 changes: 54 additions & 53 deletions src/main/java/org/owasp/validator/css/CssParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>https://issues.apache.org/jira/browse/BATIK-1112</code>
* @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 <code>https://issues.apache.org/jira/browse/BATIK-1112</code>
* @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);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 968f65b

Please sign in to comment.