Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow Whitelist test methods to be extended

Fixes #85
  • Loading branch information...
commit 3cb4cee19e3cb6830735a0f89d890576c7413f2c 1 parent caf61a4
@jhy authored
Showing with 16 additions and 1 deletion.
  1. +3 −0  CHANGES
  2. +13 −1 src/main/java/org/jsoup/safety/Whitelist.java
View
3  CHANGES
@@ -7,6 +7,9 @@ jsoup changelog
* When parsing in XML mode, preserve XML declarations (<?xml ... ?>).
<https://github.com/jhy/jsoup/issues/242>
+ * Allow Whitelist test methods to be extended
+ <https://github.com/jhy/jsoup/issues/85>
+
*** Release 1.7.1 [2012-Sep-23]
* Improved parse time, now 2.3x faster than previous release, with lower memory consumption.
View
14 src/main/java/org/jsoup/safety/Whitelist.java
@@ -319,10 +319,22 @@ public Whitelist addProtocols(String tag, String key, String... protocols) {
return this;
}
- boolean isSafeTag(String tag) {
+ /**
+ * Test if the supplied tag is allowed by this whitelist
+ * @param tag test tag
+ * @return true if allowed
+ */
+ protected boolean isSafeTag(String tag) {
return tagNames.contains(TagName.valueOf(tag));
}
+ /**
+ * Test if the supplied attribute is allowed by this whitelist for this tag
+ * @param tagName tag to consider allowing the attribute in
+ * @param el element under test, to confirm protocol
+ * @param attr attribute under test
+ * @return true if allowed
+ */
boolean isSafeAttribute(String tagName, Element el, Attribute attr) {
TagName tag = TagName.valueOf(tagName);
AttributeKey key = AttributeKey.valueOf(attr.getKey());
Please sign in to comment.
Something went wrong with that request. Please try again.