Skip to content

Commit

Permalink
add @OverRide
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Jan 7, 2024
1 parent 6e4ad43 commit 699bc7c
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/java/org/owasp/validator/css/CssHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ public Collection<String> getErrorMessages() {
*
* @see org.w3c.css.sac.DocumentHandler#comment(java.lang.String)
*/
@Override
public void comment(String text) throws CSSException {
errorMessages.add(
ErrorMessageUtil.getMessage(
Expand All @@ -184,6 +185,7 @@ public void comment(String text) throws CSSException {
*
* @see org.w3c.css.sac.DocumentHandler#ignorableAtRule(java.lang.String)
*/
@Override
public void ignorableAtRule(String atRule) throws CSSException {
// this method is called when the parser hits an unrecognized @-rule. Like the page/media/font
// declarations, this is CSS2+ stuff
Expand Down Expand Up @@ -211,6 +213,7 @@ public void ignorableAtRule(String atRule) throws CSSException {
* @see org.w3c.css.sac.DocumentHandler#importStyle(java.lang.String,
* org.w3c.css.sac.SACMediaList, java.lang.String)
*/
@Override
public void importStyle(String uri, SACMediaList media, String defaultNamespaceURI)
throws CSSException {

Expand Down Expand Up @@ -292,6 +295,7 @@ public void importStyle(String uri, SACMediaList media, String defaultNamespaceU
* @see org.w3c.css.sac.DocumentHandler#namespaceDeclaration(java.lang.String,
* java.lang.String)
*/
@Override
public void namespaceDeclaration(String prefix, String uri) throws CSSException {
// CSS3 - Namespace declaration - ignore for now
}
Expand All @@ -301,6 +305,7 @@ public void namespaceDeclaration(String prefix, String uri) throws CSSException
*
* @see org.w3c.css.sac.DocumentHandler#startDocument(org.w3c.css.sac.InputSource)
*/
@Override
public void startDocument(InputSource arg0) throws CSSException {
// no-op
}
Expand All @@ -310,6 +315,7 @@ public void startDocument(InputSource arg0) throws CSSException {
*
* @see org.w3c.css.sac.DocumentHandler#endDocument(org.w3c.css.sac.InputSource)
*/
@Override
public void endDocument(InputSource source) throws CSSException {
// no-op
}
Expand All @@ -319,6 +325,7 @@ public void endDocument(InputSource source) throws CSSException {
*
* @see org.w3c.css.sac.DocumentHandler#startFontFace()
*/
@Override
public void startFontFace() throws CSSException {
// CSS2 Font Face declaration - ignore this for now
}
Expand All @@ -328,6 +335,7 @@ public void startFontFace() throws CSSException {
*
* @see org.w3c.css.sac.DocumentHandler#endFontFace()
*/
@Override
public void endFontFace() throws CSSException {
// CSS2 Font Face declaration - ignore this for now
}
Expand All @@ -337,6 +345,7 @@ public void endFontFace() throws CSSException {
*
* @see org.w3c.css.sac.DocumentHandler#startMedia(org.w3c.css.sac.SACMediaList)
*/
@Override
public void startMedia(SACMediaList media) throws CSSException {
// CSS2 Media declaration - ignore this for now
}
Expand All @@ -346,6 +355,7 @@ public void startMedia(SACMediaList media) throws CSSException {
*
* @see org.w3c.css.sac.DocumentHandler#endMedia(org.w3c.css.sac.SACMediaList)
*/
@Override
public void endMedia(SACMediaList media) throws CSSException {
// CSS2 Media declaration - ignore this for now
}
Expand All @@ -356,6 +366,7 @@ public void endMedia(SACMediaList media) throws CSSException {
* @see org.w3c.css.sac.DocumentHandler#startPage(java.lang.String,
* java.lang.String)
*/
@Override
public void startPage(String name, String pseudoPage) throws CSSException {
// CSS2 Page declaration - ignore this for now
}
Expand All @@ -366,6 +377,7 @@ public void startPage(String name, String pseudoPage) throws CSSException {
* @see org.w3c.css.sac.DocumentHandler#endPage(java.lang.String,
* java.lang.String)
*/
@Override
public void endPage(String name, String pseudoPage) throws CSSException {
// CSS2 Page declaration - ignore this for now
}
Expand All @@ -375,6 +387,7 @@ public void endPage(String name, String pseudoPage) throws CSSException {
*
* @see org.w3c.css.sac.DocumentHandler#startSelector(org.w3c.css.sac.SelectorList)
*/
@Override
public void startSelector(SelectorList selectors) throws CSSException {

// keep track of number of valid selectors from this rule
Expand Down Expand Up @@ -455,6 +468,7 @@ public void startSelector(SelectorList selectors) throws CSSException {
*
* @see org.w3c.css.sac.DocumentHandler#endSelector(org.w3c.css.sac.SelectorList)
*/
@Override
public void endSelector(SelectorList selectors) throws CSSException {
// if we are in a state within a selector, close brace
if (selectorOpen) {
Expand All @@ -472,6 +486,7 @@ public void endSelector(SelectorList selectors) throws CSSException {
* @see org.w3c.css.sac.DocumentHandler#property(java.lang.String,
* org.w3c.css.sac.LexicalUnit, boolean)
*/
@Override
public void property(String name, LexicalUnit value, boolean important) throws CSSException {
// only bother validating and building if we are either inline or within a selector tag

Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/owasp/validator/css/CssParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class CssParser extends org.apache.batik.css.parser.Parser {
* @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 (;;) {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/owasp/validator/html/CleanResults.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public CleanResults(
this(
startOfScan,
new Callable<String>() {
@Override
public String call() throws Exception {
return cleanHTML;
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/owasp/validator/html/Policy.java
Original file line number Diff line number Diff line change
Expand Up @@ -1070,19 +1070,23 @@ private static Iterable<Element> getByTagName(Element parent, String tagName) {

final NodeList nodes = parent.getElementsByTagName(tagName);
return new Iterable<Element>() {
@Override
public Iterator<Element> iterator() {
return new Iterator<Element>() {
int pos = 0;
int len = nodes.getLength();

@Override
public boolean hasNext() {
return pos < len;
}

@Override
public Element next() {
return (Element) nodes.item(pos++);
}

@Override
public void remove() {
throw new UnsupportedOperationException("Cant remove");
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/owasp/validator/html/model/Tag.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public String getRegularExpression() {
Collections.sort(
values,
new Comparator<Attribute>() {
@Override
public int compare(Attribute o1, Attribute o2) {
return o1.getName().compareTo(o2.getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ public ASHTMLSerializer(Writer w, OutputFormat format, InternalPolicy policy) {
this.encodeAllPossibleEntities = policy.isEntityEncodeIntlCharacters();
}

@Override
protected String getEntityRef(int charToPrint) {
if (encodeAllPossibleEntities || Constants.big5CharsToEncode.indexOf(charToPrint) != -1)
return super.getEntityRef(charToPrint);
return null;
}

@Override
public void endElementIO(String namespaceURI, String localName, String rawName)
throws IOException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ public CleanResults scan(String html) throws ScanException {

Callable<String> cleanHtml =
new Callable<String>() {
@Override
public String call() throws Exception {
return trimmed;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ public CleanResults scan(String html, Policy policy) throws ScanException {
final String tainted = html;
Callable<String> cleanCallable =
new Callable<String>() {
@Override
public String call() throws Exception {
return trim(tainted, out.toString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public void reset(InternalPolicy instance) {
inCdata = false;
}

@Override
public void characters(XMLString text, Augmentations augs) throws XNIException {

Ops topOp = peekTop();
Expand All @@ -121,6 +122,7 @@ public void characters(XMLString text, Augmentations augs) throws XNIException {
private static final Pattern conditionalDirectives =
Pattern.compile("<?!?\\[\\s*(?:end)?if[^]]*\\]>?");

@Override
public void comment(XMLString text, Augmentations augs) throws XNIException {

if (preserveComments) {
Expand All @@ -134,11 +136,13 @@ public void comment(XMLString text, Augmentations augs) throws XNIException {
}
}

@Override
public void doctypeDecl(String root, String publicId, String systemId, Augmentations augs)
throws XNIException {
// user supplied doctypes are ignored
}

@Override
public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs)
throws XNIException {
this.startElement(element, attributes, augs);
Expand All @@ -154,6 +158,7 @@ private XMLString makeEndTag(String tagName) {
return new XMLString(endTag.toCharArray(), 0, endTag.length());
}

@Override
public void endElement(QName element, Augmentations augs) throws XNIException {
Ops topOp = peekTop();
if (Ops.REMOVE == topOp) {
Expand Down Expand Up @@ -224,21 +229,25 @@ private CssScanner makeCssScanner() {
return cssScanner;
}

@Override
public void processingInstruction(String target, XMLString data, Augmentations augs)
throws XNIException {
// processing instructions are being removed
}

@Override
public void startCDATA(Augmentations augs) throws XNIException {
inCdata = true;
super.startCDATA(augs);
}

@Override
public void endCDATA(Augmentations augs) throws XNIException {
inCdata = false;
super.endCDATA(augs);
}

@Override
public void startElement(QName element, XMLAttributes attributes, Augmentations augs)
throws XNIException {
// see if we have a policy for this tag.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class LiteralTest extends TestCase {

private Policy policy = null;

@Override
protected void setUp() throws Exception {

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public static TestPolicy getInstance(URL url) throws PolicyException {
return new TestPolicy(getParseContext(getTopLevelElement(url), url));
}

@Override
public TestPolicy cloneWithDirective(String name, String value) {
Map<String, String> directives = new HashMap<String, String>(this.directives);
directives.put(name, value);
Expand Down

0 comments on commit 699bc7c

Please sign in to comment.