owasp-java-html-sanitizer-0.1+r88/ 0000775 0001750 0001750 00000000000 11730105506 017461 5 ustar jamespage jamespage owasp-java-html-sanitizer-0.1+r88/pom.xml 0000664 0001750 0001750 00000003137 11730105506 021002 0 ustar jamespage jamespage
4.0.0owasp-java-html-sanitizerowasp-java-html-sanitizerr88jarOWASP Java HTML Sanitizer
A fast and easy to configure HTML Sanitizer written in Java which
lets you include HTML authored by third-parties in your web
application while protecting against XSS.
http://code.google.com/p/owasp-java-html-sanitizerOWASPhttp://www.owasp.org/New BSD Licensehttp://www.opensource.org/licenses/bsd-license.phpcom.google.guavaguavar09com.google.code.findbugsjsr3051.3.9
owasp-java-html-sanitizer-0.1+r88/src/ 0000775 0001750 0001750 00000000000 11730105506 020250 5 ustar jamespage jamespage owasp-java-html-sanitizer-0.1+r88/src/main/ 0000775 0001750 0001750 00000000000 11730105506 021174 5 ustar jamespage jamespage owasp-java-html-sanitizer-0.1+r88/src/main/java/ 0000775 0001750 0001750 00000000000 11730105507 022116 5 ustar jamespage jamespage owasp-java-html-sanitizer-0.1+r88/src/main/java/META-INF/ 0000775 0001750 0001750 00000000000 11654053470 023264 5 ustar jamespage jamespage owasp-java-html-sanitizer-0.1+r88/src/main/java/META-INF/MANIFEST.MF 0000664 0001750 0001750 00000000074 11654053470 024717 0 ustar jamespage jamespage Manifest-Version: 1.0
Created-By: 1.6.0_26 (Apple Inc.)
owasp-java-html-sanitizer-0.1+r88/src/main/java/org/ 0000775 0001750 0001750 00000000000 11654053470 022713 5 ustar jamespage jamespage owasp-java-html-sanitizer-0.1+r88/src/main/java/org/owasp/ 0000775 0001750 0001750 00000000000 11654053470 024044 5 ustar jamespage jamespage owasp-java-html-sanitizer-0.1+r88/src/main/java/org/owasp/html/ 0000775 0001750 0001750 00000000000 11654053470 025010 5 ustar jamespage jamespage owasp-java-html-sanitizer-0.1+r88/src/main/java/org/owasp/html/ElementAndAttributePolicies.java 0000664 0001750 0001750 00000006677 11654053470 033263 0 ustar jamespage jamespage // Copyright (c) 2011, Mike Samuel
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// Neither the name of the OWASP nor the names of its contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
package org.owasp.html;
import java.util.Map;
import com.google.common.collect.ImmutableMap;
import javax.annotation.concurrent.Immutable;
/**
* Encapsulates all the information needed by the
* {@link ElementAndAttributePolicyBasedSanitizerPolicy} to sanitize one kind
* of element.
*/
@Immutable
final class ElementAndAttributePolicies {
final String elementName;
final boolean isVoid;
final ElementPolicy elPolicy;
final ImmutableMap attrPolicies;
final boolean skipIfEmpty;
ElementAndAttributePolicies(
String elementName,
ElementPolicy elPolicy,
Map extends String, ? extends AttributePolicy>
attrPolicies,
boolean skipIfEmpty) {
this.elementName = elementName;
this.isVoid = HtmlTextEscapingMode.isVoidElement(elementName);
this.elPolicy = elPolicy;
this.attrPolicies = ImmutableMap.copyOf(attrPolicies);
this.skipIfEmpty = skipIfEmpty;
}
ElementAndAttributePolicies and(ElementAndAttributePolicies p) {
assert elementName.equals(p.elementName):
elementName + " != " + p.elementName;
ImmutableMap.Builder joinedAttrPolicies
= ImmutableMap.builder();
for (Map.Entry e : this.attrPolicies.entrySet()) {
String attrName = e.getKey();
AttributePolicy a = e.getValue();
AttributePolicy b = p.attrPolicies.get(attrName);
if (b != null) {
a = AttributePolicy.Util.join(a, b);
}
joinedAttrPolicies.put(attrName, a);
}
for (Map.Entry e : p.attrPolicies.entrySet()) {
String attrName = e.getKey();
if (!this.attrPolicies.containsKey(attrName)) {
joinedAttrPolicies.put(attrName, e.getValue());
}
}
return new ElementAndAttributePolicies(
elementName,
ElementPolicy.Util.join(elPolicy, p.elPolicy),
joinedAttrPolicies.build(),
skipIfEmpty || p.skipIfEmpty);
}
}
././@LongLink 0000000 0000000 0000000 00000000147 00000000000 011567 L ustar root root owasp-java-html-sanitizer-0.1+r88/src/main/java/org/owasp/html/FilterUrlByProtocolAttributePolicy.java owasp-java-html-sanitizer-0.1+r88/src/main/java/org/owasp/html/FilterUrlByProtocolAttributePolicy.ja0000664 0001750 0001750 00000011606 11654053470 034321 0 ustar jamespage jamespage // Copyright (c) 2011, Mike Samuel
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// Neither the name of the OWASP nor the names of its contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
package org.owasp.html;
import javax.annotation.Nullable;
import com.google.common.collect.ImmutableSet;
/**
* An attribute policy for attributes whose values are URLs that requires that
* the value have no protocol or have an allowed protocol.
*
*
* URLs with protocols must match the protocol set passed to the constructor.
* URLs without protocols but which specify an origin different from the
* containing page (e.g. {@code //example.org}) are only allowed if the
* {@link FilterUrlByProtocolAttributePolicy#allowProtocolRelativeUrls policy}
* allows both {@code http} and {@code https} which are normally used to serve
* HTML.
* Same-origin URLs, URLs without any protocol or authority part are always
* allowed.
*
*
*
* This class assumes that URLs are either hierarchical, or are opaque, but
* do not look like they contain an authority portion.
*
* Slashdot (http://www.slashdot.org/) is a techie news site that allows users
* to respond anonymously to news posts with very limited HTML markup. Now
* Slashdot is not only one of the coolest sites around, it's also one that's
* been subject to many different successful attacks. Even more unfortunate is
* the fact that most of the attacks led users to the infamous goatse.cx picture
* (please don't go look it up). The rules for Slashdot are fairly strict: users
* can only submit the following HTML tags and no CSS: {@code }, {@code },
* {@code }, {@code }, {@code
* eBay (http://www.ebay.com/) is the most popular online auction site in the
* universe, as far as I can tell. It is a public site so anyone is allowed to
* post listings with rich HTML content. It's not surprising that given the
* attractiveness of eBay as a target that it has been subject to a few complex
* XSS attacks. Listings are allowed to contain much more rich content than,
* say, Slashdot- so it's attack surface is considerably larger. The following
* tags appear to be accepted by eBay (they don't publish rules):
* {@code },...
*
*/
public class EbayPolicyExample {
// Some common regular expression definitions.
// The 16 colors defined by the HTML Spec (also used by the CSS Spec)
private static final Pattern COLOR_NAME = Pattern.compile(
"(?:aqua|black|blue|fuchsia|gray|grey|green|lime|maroon|navy|olive|purple"
+ "|red|silver|teal|white|yellow)");
// HTML/CSS Spec allows 3 or 6 digit hex to specify color
private static final Pattern COLOR_CODE = Pattern.compile(
"(?:#(?:[0-9a-fA-F]{3}(?:[0-9a-fA-F]{3})?))");
private static final Pattern NUMBER_OR_PERCENT = Pattern.compile(
"[0-9]+%?");
private static final Pattern PARAGRAPH = Pattern.compile(
"(?:[\\p{L}\\p{N},'\\.\\s\\-_\\(\\)]|&[0-9]{2};)*");
private static final Pattern HTML_ID = Pattern.compile(
"[a-zA-Z0-9\\:\\-_\\.]+");
// force non-empty with a '+' at the end instead of '*'
private static final Pattern HTML_TITLE = Pattern.compile(
"[\\p{L}\\p{N}\\s\\-_',:\\[\\]!\\./\\\\\\(\\)&]*");
private static final Pattern HTML_CLASS = Pattern.compile(
"[a-zA-Z0-9\\s,\\-_]+");
private static final Pattern ONSITE_URL = Pattern.compile(
"(?:[\\p{L}\\p{N}\\\\\\.\\#@\\$%\\+&;\\-_~,\\?=/!]+|\\#(\\w)+)");
private static final Pattern OFFSITE_URL = Pattern.compile(
"\\s*(?:(?:ht|f)tps?://|mailto:)[\\p{L}\\p{N}]"
+ "[\\p{L}\\p{N}\\p{Zs}\\.\\#@\\$%\\+&;:\\-_~,\\?=/!\\(\\)]*\\s*");
private static final Pattern NUMBER = Pattern.compile(
"[+-]?(?:(?:[0-9]+(?:\\.[0-9]*)?)|\\.[0-9]+)");
private static final Pattern NAME = Pattern.compile("[a-zA-Z0-9\\-_\\$]+");
private static final Pattern ALIGN = Pattern.compile(
"(?i)center|left|right|justify|char");
private static final Pattern VALIGN = Pattern.compile(
"(?i)baseline|bottom|middle|top");
private static final Predicate COLOR_NAME_OR_COLOR_CODE
= new Predicate() {
public boolean apply(String s) {
return COLOR_NAME.matcher(s).matches()
|| COLOR_CODE.matcher(s).matches();
}
};
private static final Predicate ONSITE_OR_OFFSITE_URL
= new Predicate() {
public boolean apply(String s) {
return ONSITE_URL.matcher(s).matches()
|| OFFSITE_URL.matcher(s).matches();
}
};
private static final Pattern HISTORY_BACK = Pattern.compile(
"(?:javascript:)?\\Qhistory.go(-1)\\E");
private static final Pattern ONE_CHAR = Pattern.compile(
".?", Pattern.DOTALL);
public static final Function
POLICY_DEFINITION = new HtmlPolicyBuilder()
.allowAttributes("id").matching(HTML_ID).globally()
.allowAttributes("class").matching(HTML_CLASS).globally()
.allowAttributes("lang").matching(Pattern.compile("[a-zA-Z]{2,20}"))
.globally()
.allowAttributes("title").matching(HTML_TITLE).globally()
.allowStyling()
.allowAttributes("align").matching(ALIGN).onElements("p")
.allowAttributes("for").matching(HTML_ID).onElements("label")
.allowAttributes("color").matching(COLOR_NAME_OR_COLOR_CODE)
.onElements("font")
.allowAttributes("face")
.matching(Pattern.compile("[\\w;, \\-]+"))
.onElements("font")
.allowAttributes("size").matching(NUMBER).onElements("font")
.allowAttributes("href").matching(ONSITE_OR_OFFSITE_URL)
.onElements("a")
.allowStandardUrlProtocols()
.allowAttributes("nohref").onElements("a")
.allowAttributes("name").matching(NAME).onElements("a")
.allowAttributes(
"onfocus", "onblur", "onclick", "onmousedown", "onmouseup")
.matching(HISTORY_BACK).onElements("a")
.requireRelNofollowOnLinks()
.allowAttributes("src").matching(ONSITE_OR_OFFSITE_URL)
.onElements("img")
.allowAttributes("name").matching(NAME)
.onElements("img")
.allowAttributes("alt").matching(PARAGRAPH)
.onElements("img")
.allowAttributes("border", "hspace", "vspace").matching(NUMBER)
.onElements("img")
.allowAttributes("border", "cellpadding", "cellspacing")
.matching(NUMBER).onElements("table")
.allowAttributes("bgcolor").matching(COLOR_NAME_OR_COLOR_CODE)
.onElements("table")
.allowAttributes("background").matching(ONSITE_URL)
.onElements("table")
.allowAttributes("align").matching(ALIGN)
.onElements("table")
.allowAttributes("noresize").matching(Pattern.compile("(?i)noresize"))
.onElements("table")
.allowAttributes("background").matching(ONSITE_URL)
.onElements("td", "th", "tr")
.allowAttributes("bgcolor").matching(COLOR_NAME_OR_COLOR_CODE)
.onElements("td", "th")
.allowAttributes("abbr").matching(PARAGRAPH)
.onElements("td", "th")
.allowAttributes("axis", "headers").matching(NAME)
.onElements("td", "th")
.allowAttributes("scope")
.matching(Pattern.compile("(?i)(?:row|col)(?:group)?"))
.onElements("td", "th")
.allowAttributes("nowrap")
.onElements("td", "th")
.allowAttributes("height", "width").matching(NUMBER_OR_PERCENT)
.onElements("table", "td", "th", "tr", "img")
.allowAttributes("align").matching(ALIGN)
.onElements("thead", "tbody", "tfoot", "img",
"td", "th", "tr", "colgroup", "col")
.allowAttributes("valign").matching(VALIGN)
.onElements("thead", "tbody", "tfoot",
"td", "th", "tr", "colgroup", "col")
.allowAttributes("charoff").matching(NUMBER_OR_PERCENT)
.onElements("td", "th", "tr", "colgroup", "col",
"thead", "tbody", "tfoot")
.allowAttributes("char").matching(ONE_CHAR)
.onElements("td", "th", "tr", "colgroup", "col",
"thead", "tbody", "tfoot")
.allowAttributes("colspan", "rowspan").matching(NUMBER)
.onElements("td", "th")
.allowAttributes("span", "width").matching(NUMBER_OR_PERCENT)
.onElements("colgroup", "col")
.allowElements(
"label", "noscript", "h1", "h2", "h3", "h4", "h5", "h6",
"p", "i", "b", "u", "strong", "em", "small", "big", "pre", "code",
"cite", "samp", "sub", "sup", "strike", "center", "blockquote",
"hr", "br", "col", "font", "map", "span", "div", "img",
"ul", "ol", "li", "dd", "dt", "dl", "tbody", "thead", "tfoot",
"table", "td", "th", "tr", "colgroup", "fieldset", "legend")
.toFactory();
public static void main(String[] args) throws IOException {
if (args.length != 0) {
System.err.println("Reads from STDIN and writes to STDOUT");
System.exit(-1);
}
System.err.println("[Reading from STDIN]");
// Fetch the HTML to sanitize.
String html = CharStreams.toString(
new InputStreamReader(System.in, Charsets.UTF_8));
// Set up an output channel to receive the sanitized HTML.
HtmlStreamRenderer renderer = HtmlStreamRenderer.create(
System.out,
// Receives notifications on a failure to write to the output.
new Handler() {
public void handle(IOException ex) {
Throwables.propagate(ex); // System.out suppresses IOExceptions
}
},
// Our HTML parser is very lenient, but this receives notifications on
// truly bizarre inputs.
new Handler() {
public void handle(String x) {
throw new AssertionError(x);
}
});
// Use the policy defined above to sanitize the HTML.
HtmlSanitizer.sanitize(html, POLICY_DEFINITION.apply(renderer));
}
}
owasp-java-html-sanitizer-0.1+r88/src/main/java/org/owasp/html/ElementPolicy.java 0000664 0001750 0001750 00000011236 11654053470 030427 0 ustar jamespage jamespage // Copyright (c) 2011, Mike Samuel
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// Neither the name of the OWASP nor the names of its contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
package org.owasp.html;
import java.util.List;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
/**
* A policy that can be applied to an element to decide whether or not to
* allow it in the output, possibly after transforming attributes.
*
* Element policies are applied after
* {@link AttributePolicy attribute policies} so
* they can be used to add extra attributes.
*
* @author Mike Samuel
* @see HtmlPolicyBuilder#allowElements(ElementPolicy, String...)
*/
@TCB public interface ElementPolicy {
/**
* @param elementName the lower-case element name.
* @param attrs a list of alternating attribute names and values.
* The list may be added to or removed from. When removing, be
* careful to remove both the name and its associated value.
*
* @return {@code null} to disallow the element, or the adjusted element name.
*/
public @Nullable String apply(String elementName, List attrs);
/** Utilities for working with element policies. */
public static final class Util {
private Util() { /* uninstantiable */ }
/**
* Given zero or more element policies, returns an element policy equivalent
* to applying them in order failing early if any of them fails.
*/
public static final ElementPolicy join(ElementPolicy... policies) {
class PolicyJoiner {
ElementPolicy last = null;
ElementPolicy out = null;
void join(ElementPolicy p) {
if (p == REJECT_ALL_ELEMENT_POLICY) {
out = p;
} else if (out != REJECT_ALL_ELEMENT_POLICY) {
if (p instanceof JoinedElementPolicy) {
JoinedElementPolicy jep = (JoinedElementPolicy) p;
join(jep.first);
join(jep.second);
} else if (p != last) {
last = p;
if (out == null || out == IDENTITY_ELEMENT_POLICY) {
out = p;
} else if (p != IDENTITY_ELEMENT_POLICY) {
out = new JoinedElementPolicy(out, p);
}
}
}
}
}
PolicyJoiner pu = new PolicyJoiner();
for (ElementPolicy policy : policies) {
if (policy == null) { continue; }
pu.join(policy);
}
return pu.out != null ? pu.out : IDENTITY_ELEMENT_POLICY;
}
}
public static final ElementPolicy IDENTITY_ELEMENT_POLICY
= new ElementPolicy() {
public String apply(String elementName, List attrs) {
return elementName;
}
};
public static final ElementPolicy REJECT_ALL_ELEMENT_POLICY
= new ElementPolicy() {
public @Nullable String apply(String elementName, List attrs) {
return null;
}
};
}
@Immutable
final class JoinedElementPolicy implements ElementPolicy {
final ElementPolicy first, second;
JoinedElementPolicy(ElementPolicy first, ElementPolicy second) {
this.first = first;
this.second = second;
}
public @Nullable String apply(String elementName, List attrs) {
elementName = first.apply(elementName, attrs);
return elementName != null ? second.apply(elementName, attrs) : null;
}
}
owasp-java-html-sanitizer-0.1+r88/src/main/java/org/owasp/html/package-info.java 0000664 0001750 0001750 00000003445 11654053470 030205 0 ustar jamespage jamespage // Copyright (c) 2011, Mike Samuel
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// Neither the name of the OWASP nor the names of its contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
/**
* An efficient {@link org.owasp.html.HtmlSanitizer HtmlSanitizer}
* configurable via a flexible
* {@link org.owasp.html.HtmlPolicyBuilder HtmlPolicyBuilder}.
*
* @author Mike Samuel
*/
@javax.annotation.ParametersAreNonnullByDefault
package org.owasp.html;
owasp-java-html-sanitizer-0.1+r88/src/main/java/org/owasp/html/Handler.java 0000664 0001750 0001750 00000004265 11654053470 027237 0 ustar jamespage jamespage // Copyright (c) 2011, Mike Samuel
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// Neither the name of the OWASP nor the names of its contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
package org.owasp.html;
import com.google.common.base.Throwables;
/**
* Receives notification of problems.
*
* @author Mike Samuel
*/
public interface Handler {
void handle(T x);
/** A handler that does nothing given any input. */
public static final Handler