diff --git a/src/main/java/org/owasp/validator/css/CssHandler.java b/src/main/java/org/owasp/validator/css/CssHandler.java index 381402d6..7be3875d 100644 --- a/src/main/java/org/owasp/validator/css/CssHandler.java +++ b/src/main/java/org/owasp/validator/css/CssHandler.java @@ -171,6 +171,7 @@ public Collection getErrorMessages() { * * @see org.w3c.css.sac.DocumentHandler#comment(java.lang.String) */ + @Override public void comment(String text) throws CSSException { errorMessages.add( ErrorMessageUtil.getMessage( @@ -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 @@ -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 { @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 @@ -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) { @@ -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 diff --git a/src/main/java/org/owasp/validator/css/CssParser.java b/src/main/java/org/owasp/validator/css/CssParser.java index dd13ee83..2ae2f638 100644 --- a/src/main/java/org/owasp/validator/css/CssParser.java +++ b/src/main/java/org/owasp/validator/css/CssParser.java @@ -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 (;;) { diff --git a/src/main/java/org/owasp/validator/html/CleanResults.java b/src/main/java/org/owasp/validator/html/CleanResults.java index ed7f5377..fad145a7 100644 --- a/src/main/java/org/owasp/validator/html/CleanResults.java +++ b/src/main/java/org/owasp/validator/html/CleanResults.java @@ -98,6 +98,7 @@ public CleanResults( this( startOfScan, new Callable() { + @Override public String call() throws Exception { return cleanHTML; } diff --git a/src/main/java/org/owasp/validator/html/Policy.java b/src/main/java/org/owasp/validator/html/Policy.java index e700cff2..92a4fdd3 100644 --- a/src/main/java/org/owasp/validator/html/Policy.java +++ b/src/main/java/org/owasp/validator/html/Policy.java @@ -1070,19 +1070,23 @@ private static Iterable getByTagName(Element parent, String tagName) { final NodeList nodes = parent.getElementsByTagName(tagName); return new Iterable() { + @Override public Iterator iterator() { return new Iterator() { 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"); } diff --git a/src/main/java/org/owasp/validator/html/model/Tag.java b/src/main/java/org/owasp/validator/html/model/Tag.java index fef0af6c..0a918f25 100644 --- a/src/main/java/org/owasp/validator/html/model/Tag.java +++ b/src/main/java/org/owasp/validator/html/model/Tag.java @@ -97,6 +97,7 @@ public String getRegularExpression() { Collections.sort( values, new Comparator() { + @Override public int compare(Attribute o1, Attribute o2) { return o1.getName().compareTo(o2.getName()); } diff --git a/src/main/java/org/owasp/validator/html/scan/ASHTMLSerializer.java b/src/main/java/org/owasp/validator/html/scan/ASHTMLSerializer.java index d1263d5a..104f66a2 100644 --- a/src/main/java/org/owasp/validator/html/scan/ASHTMLSerializer.java +++ b/src/main/java/org/owasp/validator/html/scan/ASHTMLSerializer.java @@ -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 { diff --git a/src/main/java/org/owasp/validator/html/scan/AntiSamyDOMScanner.java b/src/main/java/org/owasp/validator/html/scan/AntiSamyDOMScanner.java index cd4c6794..ca754867 100644 --- a/src/main/java/org/owasp/validator/html/scan/AntiSamyDOMScanner.java +++ b/src/main/java/org/owasp/validator/html/scan/AntiSamyDOMScanner.java @@ -200,6 +200,7 @@ public CleanResults scan(String html) throws ScanException { Callable cleanHtml = new Callable() { + @Override public String call() throws Exception { return trimmed; } diff --git a/src/main/java/org/owasp/validator/html/scan/AntiSamySAXScanner.java b/src/main/java/org/owasp/validator/html/scan/AntiSamySAXScanner.java index bd9af8c7..352bc509 100644 --- a/src/main/java/org/owasp/validator/html/scan/AntiSamySAXScanner.java +++ b/src/main/java/org/owasp/validator/html/scan/AntiSamySAXScanner.java @@ -182,6 +182,7 @@ public CleanResults scan(String html, Policy policy) throws ScanException { final String tainted = html; Callable cleanCallable = new Callable() { + @Override public String call() throws Exception { return trim(tainted, out.toString()); } 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 273a5c05..2b3a1159 100644 --- a/src/main/java/org/owasp/validator/html/scan/MagicSAXFilter.java +++ b/src/main/java/org/owasp/validator/html/scan/MagicSAXFilter.java @@ -98,6 +98,7 @@ public void reset(InternalPolicy instance) { inCdata = false; } + @Override public void characters(XMLString text, Augmentations augs) throws XNIException { Ops topOp = peekTop(); @@ -121,6 +122,7 @@ public void characters(XMLString text, Augmentations augs) throws XNIException { private static final Pattern conditionalDirectives = Pattern.compile("?"); + @Override public void comment(XMLString text, Augmentations augs) throws XNIException { if (preserveComments) { @@ -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); @@ -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) { @@ -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. diff --git a/src/test/java/org/owasp/validator/html/test/LiteralTest.java b/src/test/java/org/owasp/validator/html/test/LiteralTest.java index 60aa5f4f..7f15462b 100644 --- a/src/test/java/org/owasp/validator/html/test/LiteralTest.java +++ b/src/test/java/org/owasp/validator/html/test/LiteralTest.java @@ -43,6 +43,7 @@ public class LiteralTest extends TestCase { private Policy policy = null; + @Override protected void setUp() throws Exception { /* diff --git a/src/test/java/org/owasp/validator/html/test/TestPolicy.java b/src/test/java/org/owasp/validator/html/test/TestPolicy.java index 62880300..e260878b 100644 --- a/src/test/java/org/owasp/validator/html/test/TestPolicy.java +++ b/src/test/java/org/owasp/validator/html/test/TestPolicy.java @@ -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 directives = new HashMap(this.directives); directives.put(name, value);