public class CssScanner extends Object
scanInlineSheet()
or
scanStyleSheet
as appropriate.scanInlineStyle(String, String, int)
,
scanStyleSheet(String, int)
Modifier and Type | Field and Description |
---|---|
protected static int |
DEFAULT_TIMEOUT |
Constructor and Description |
---|
CssScanner(InternalPolicy policy,
ResourceBundle messages)
Constructs a scanner based on the given policy.
|
CssScanner(InternalPolicy policy,
ResourceBundle messages,
boolean shouldParseImportedStyles)
Constructs a scanner based on the given policy.
|
Modifier and Type | Method and Description |
---|---|
CleanResults |
scanInlineStyle(String taintedCss,
String tagName,
int sizeLimit)
Scans the contents of an inline style declaration (ex.
|
CleanResults |
scanStyleSheet(String taintedCss,
int sizeLimit)
Scans the contents of a full stylesheet (ex.
|
protected static final int DEFAULT_TIMEOUT
public CssScanner(InternalPolicy policy, ResourceBundle messages)
policy
- the policy to follow when scanningmessages
- the error message bundle to pull frompublic CssScanner(InternalPolicy policy, ResourceBundle messages, boolean shouldParseImportedStyles)
policy
- the policy to follow when scanningmessages
- the error message bundle to pull fromshouldParseImportedStyles
- Flag to indicate if styles within @import directives should be imported and
parsed in the resulting style sheet. This boolean determines if URLs should be
recognized when parsing styles (i.e., to fetch them or ignore them).public CleanResults scanStyleSheet(String taintedCss, int sizeLimit) throws ScanException
taintedCss
- a String
containing the contents of the
CSS stylesheet to validatesizeLimit
- the limit on the total size in bytes of any imported
stylesheetsCleanResuts
object containing the results of
the scanScanException
- if an error occurs during scanningpublic CleanResults scanInlineStyle(String taintedCss, String tagName, int sizeLimit) throws ScanException
CssScanner
's policy file.taintedCss
- a String
containing the contents of the
CSS stylesheet to validatetagName
- the name of the tag for which this inline style was
declaredsizeLimit
- the limit on the total size in bites of any imported
stylesheetsCleanResuts
object containing the results of
the scanScanException
- if an error occurs during scanningCopyright © 2022. All rights reserved.