From 8a597925a7dae0b3bce86b1b5638699abed72331 Mon Sep 17 00:00:00 2001 From: Jonathan Hedley Date: Wed, 18 Oct 2023 13:18:37 +1100 Subject: [PATCH] Make isSafe* public Fixes #1780 --- CHANGES | 3 +++ src/main/java/org/jsoup/safety/Safelist.java | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index cd8bfe6a0d..ed8d120c2c 100644 --- a/CHANGES +++ b/CHANGES @@ -35,6 +35,9 @@ Release 1.16.2 [PENDING] * Improvement: in forms, should be excluded from formData() (and hence from form submissions). + * Improvement: in Safelist, made isSafeTag and isSafeAttribute public methods, for extensibility. + + * Bugfix: `form` elements and empty elements (such as `img`) did not have their attributes de-duplicated. diff --git a/src/main/java/org/jsoup/safety/Safelist.java b/src/main/java/org/jsoup/safety/Safelist.java index 75e80b8901..abfda3b076 100644 --- a/src/main/java/org/jsoup/safety/Safelist.java +++ b/src/main/java/org/jsoup/safety/Safelist.java @@ -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());