Skip to content

Commit

Permalink
Make isSafe* public
Browse files Browse the repository at this point in the history
Fixes #1780
  • Loading branch information
jhy committed Oct 18, 2023
1 parent 5f20fcc commit 8a59792
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ Release 1.16.2 [PENDING]
* Improvement: in forms, <input type="image"> should be excluded from formData() (and hence from form submissions).
<https://github.com/jhy/jsoup/pull/2010>

* Improvement: in Safelist, made isSafeTag and isSafeAttribute public methods, for extensibility.
<https://github.com/jhy/jsoup/issues/1780>

* Bugfix: `form` elements and empty elements (such as `img`) did not have their attributes de-duplicated.
<https://github.com/jhy/jsoup/pull/1950>

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/jsoup/safety/Safelist.java
Original file line number Diff line number Diff line change
Expand Up @@ -522,22 +522,22 @@ public Safelist removeProtocols(String tag, String attribute, String... removePr
}

/**
* Test if the supplied tag is allowed by this safelist
* Test if the supplied tag is allowed by this safelist.
* @param tag test tag
* @return true if allowed
*/
protected boolean isSafeTag(String tag) {
public boolean isSafeTag(String tag) {
return tagNames.contains(TagName.valueOf(tag));
}

/**
* Test if the supplied attribute is allowed by this safelist for this tag
* Test if the supplied attribute is allowed by this safelist 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
*/
protected boolean isSafeAttribute(String tagName, Element el, Attribute attr) {
public boolean isSafeAttribute(String tagName, Element el, Attribute attr) {
TagName tag = TagName.valueOf(tagName);
AttributeKey key = AttributeKey.valueOf(attr.getKey());

Expand Down

0 comments on commit 8a59792

Please sign in to comment.