Package org.owasp.validator.css
Class CssHandler
java.lang.Object
org.owasp.validator.css.CssHandler
- All Implemented Interfaces:
org.w3c.css.sac.DocumentHandler
A implementation of a SAC DocumentHandler for CSS validation. The appropriate
validation method is called whenever the handler is invoked by the parser.
The handler also builds a clean CSS document as the original CSS is scanned.
NOTE: keeping state in this class is not ideal as handler style parsing a la
SAX should generally be event driven. However, there is not a fully
implemented "DOM" equivalent to CSS at this time. Java has a StyleSheet class
that could accomplish this "DOM" like behavior but it has yet to be fully
implemented.
- Author:
- Jason Li
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCssHandler
(Policy policy, LinkedList embeddedStyleSheets, List<String> errorMessages, String tagName, ResourceBundle messages) Constructs a handler for inline style declarations using the given policy and queue for imported stylesheets.CssHandler
(Policy policy, LinkedList embeddedStyleSheets, List<String> errorMessages, ResourceBundle messages) Constructs a handler for stylesheets using the given policy and queue for imported stylesheets. -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
endDocument
(org.w3c.css.sac.InputSource source) void
void
endMedia
(org.w3c.css.sac.SACMediaList media) void
void
endSelector
(org.w3c.css.sac.SelectorList selectors) Returns the cleaned stylesheet.Returns the error messages generated during parsing.void
ignorableAtRule
(String atRule) void
importStyle
(String uri, org.w3c.css.sac.SACMediaList media, String defaultNamespaceURI) void
namespaceDeclaration
(String prefix, String uri) void
void
startDocument
(org.w3c.css.sac.InputSource arg0) void
void
startMedia
(org.w3c.css.sac.SACMediaList media) void
void
startSelector
(org.w3c.css.sac.SelectorList selectors)
-
Constructor Details
-
CssHandler
public CssHandler(Policy policy, LinkedList embeddedStyleSheets, List<String> errorMessages, ResourceBundle messages) Constructs a handler for stylesheets using the given policy and queue for imported stylesheets.- Parameters:
policy
- the policy to useembeddedStyleSheets
- the queue of stylesheets imported
-
CssHandler
public CssHandler(Policy policy, LinkedList embeddedStyleSheets, List<String> errorMessages, String tagName, ResourceBundle messages) Constructs a handler for inline style declarations using the given policy and queue for imported stylesheets.- Parameters:
policy
- the policy to useembeddedStyleSheets
- the queue of stylesheets importedtagName
- the associated tag name with this inline style
-
-
Method Details
-
getCleanStylesheet
Returns the cleaned stylesheet.- Returns:
- the cleaned styesheet
-
getErrorMessages
Returns the error messages generated during parsing.- Returns:
- the error messages generated during parsing
-
comment
- Specified by:
comment
in interfaceorg.w3c.css.sac.DocumentHandler
- Throws:
org.w3c.css.sac.CSSException
-
ignorableAtRule
- Specified by:
ignorableAtRule
in interfaceorg.w3c.css.sac.DocumentHandler
- Throws:
org.w3c.css.sac.CSSException
-
importStyle
public void importStyle(String uri, org.w3c.css.sac.SACMediaList media, String defaultNamespaceURI) throws org.w3c.css.sac.CSSException - Specified by:
importStyle
in interfaceorg.w3c.css.sac.DocumentHandler
- Throws:
org.w3c.css.sac.CSSException
-
namespaceDeclaration
- Specified by:
namespaceDeclaration
in interfaceorg.w3c.css.sac.DocumentHandler
- Throws:
org.w3c.css.sac.CSSException
-
startDocument
public void startDocument(org.w3c.css.sac.InputSource arg0) throws org.w3c.css.sac.CSSException - Specified by:
startDocument
in interfaceorg.w3c.css.sac.DocumentHandler
- Throws:
org.w3c.css.sac.CSSException
-
endDocument
public void endDocument(org.w3c.css.sac.InputSource source) throws org.w3c.css.sac.CSSException - Specified by:
endDocument
in interfaceorg.w3c.css.sac.DocumentHandler
- Throws:
org.w3c.css.sac.CSSException
-
startFontFace
public void startFontFace() throws org.w3c.css.sac.CSSException- Specified by:
startFontFace
in interfaceorg.w3c.css.sac.DocumentHandler
- Throws:
org.w3c.css.sac.CSSException
-
endFontFace
public void endFontFace() throws org.w3c.css.sac.CSSException- Specified by:
endFontFace
in interfaceorg.w3c.css.sac.DocumentHandler
- Throws:
org.w3c.css.sac.CSSException
-
startMedia
public void startMedia(org.w3c.css.sac.SACMediaList media) throws org.w3c.css.sac.CSSException - Specified by:
startMedia
in interfaceorg.w3c.css.sac.DocumentHandler
- Throws:
org.w3c.css.sac.CSSException
-
endMedia
public void endMedia(org.w3c.css.sac.SACMediaList media) throws org.w3c.css.sac.CSSException - Specified by:
endMedia
in interfaceorg.w3c.css.sac.DocumentHandler
- Throws:
org.w3c.css.sac.CSSException
-
startPage
- Specified by:
startPage
in interfaceorg.w3c.css.sac.DocumentHandler
- Throws:
org.w3c.css.sac.CSSException
-
endPage
- Specified by:
endPage
in interfaceorg.w3c.css.sac.DocumentHandler
- Throws:
org.w3c.css.sac.CSSException
-
startSelector
public void startSelector(org.w3c.css.sac.SelectorList selectors) throws org.w3c.css.sac.CSSException - Specified by:
startSelector
in interfaceorg.w3c.css.sac.DocumentHandler
- Throws:
org.w3c.css.sac.CSSException
-
endSelector
public void endSelector(org.w3c.css.sac.SelectorList selectors) throws org.w3c.css.sac.CSSException - Specified by:
endSelector
in interfaceorg.w3c.css.sac.DocumentHandler
- Throws:
org.w3c.css.sac.CSSException
-
property
public void property(String name, org.w3c.css.sac.LexicalUnit value, boolean important) throws org.w3c.css.sac.CSSException - Specified by:
property
in interfaceorg.w3c.css.sac.DocumentHandler
- Throws:
org.w3c.css.sac.CSSException
-