Skip to content

Commit c1cf417

Browse files
Merge branch 'main' into migrate_to_jupiter
2 parents 42e18a1 + 3dc7b8e commit c1cf417

8 files changed

Lines changed: 61 additions & 8 deletions

File tree

RELEASE-checklist.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ perl -i.bak \
6969
-pe 'if (m/^ [*] / && !$added) { $_ = qq( * Release $ENV{"NEW_VERSION"}\n$_); $added = 1; }' \
7070
change_log.md
7171

72-
$EDITOR change_log.md
72+
$EDITOR change_log.md SECURITY.md
7373

7474
# A dry run.
7575
mvn -f pom.xml clean source:jar javadoc:jar verify \

SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Only the lastest version are supported with updates.
66

77
| Version | Supported |
88
| ---------- | ------------------ |
9-
| 20240325.1 | :white_check_mark: |
9+
| 20260103.1 | :white_check_mark: |
1010

1111

1212

docs/vulnerabilities.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Known & public vulnerabilities in this project
22

3+
* [CVE-2025-66021](https://github.com/OWASP/java-html-sanitizer/security/advisories/GHSA-g9gq-3pfx-2gw2) - 25 Nov. 2025 - Recommend upgrade to v20260102.1 or later.
34
* [CVE-2021-42575](cve202142575.md) - 18 Oct. 2021 - Recommend upgrade to v20211018.1 or later.
45
* [CVE-2011-4457](cve20114457.md) - 17 Nov. 2011 - Recommend upgrade to r88 or later.

java10-shim/src/main/java/org/owasp/shim/ForJava9AndLater.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@ final class ForJava9AndLater extends Java8Shim {
6262
}
6363

6464
@Override public <T> Set<T> setCopyOf(Collection<? extends T> c) {
65-
return Set.copyOf(c);
65+
return Collections.unmodifiableSet(new LinkedHashSet<>(c));
6666
}
6767
}

owasp-java-html-sanitizer/src/main/java/org/owasp/html/HtmlElementTables.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public HtmlElementTables(
109109
LI_TAG = indexForName("li");
110110
SELECT_TAG = indexForName("select");
111111
OPTION_TAG = indexForName("option");
112-
OPTGROUP_TAG = indexForName("opgroup");
112+
OPTGROUP_TAG = indexForName("optgroup");
113113
SCRIPT_TAG = indexForName("script");
114114
STYLE_TAG = indexForName("style");
115115
TABLE_TAG = indexForName("table");

owasp-java-html-sanitizer/src/main/java/org/owasp/html/HtmlPolicyBuilder.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.util.HashMap;
3434
import java.util.HashSet;
3535
import java.util.LinkedHashMap;
36+
import java.util.LinkedHashSet;
3637
import java.util.List;
3738
import java.util.Map;
3839
import java.util.Set;
@@ -428,7 +429,7 @@ public HtmlPolicyBuilder requireRelNofollowOnLinks() {
428429
public HtmlPolicyBuilder requireRelsOnLinks(String... linkValues) {
429430
this.invalidateCompiledState();
430431
if (this.extraRelsForLinks == null) {
431-
this.extraRelsForLinks = new HashSet<>();
432+
this.extraRelsForLinks = new LinkedHashSet<>();
432433
}
433434
for (String linkValue : linkValues) {
434435
linkValue = HtmlLexer.canonicalKeywordAttributeValue(linkValue);
@@ -1112,8 +1113,8 @@ static final class JoinRelsOnLinksPolicies
11121113

11131114
public JoinableElementPolicy join(
11141115
Iterable<? extends JoinableElementPolicy> toJoin) {
1115-
Set<String> extra = new HashSet<>();
1116-
Set<String> skip = new HashSet<>();
1116+
Set<String> extra = new LinkedHashSet<>();
1117+
Set<String> skip = new LinkedHashSet<>();
11171118
for (JoinableElementPolicy ep : toJoin) {
11181119
RelsOnLinksPolicy p = (RelsOnLinksPolicy) ep;
11191120
extra.addAll(p.extra);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.owasp.html;
2+
3+
import org.junit.Test;
4+
import static org.junit.Assert.assertEquals;
5+
6+
public class OptgroupBugTest {
7+
8+
/**
9+
* Test that optgroup elements inside select are not corrupted with extra select tags.
10+
*
11+
* Before fix: <select><optgroup><select><option></option></select></optgroup></select>
12+
* After fix: <select><optgroup><option></option></optgroup></select>
13+
*/
14+
@Test
15+
public void testOptgroupInsideSelectDoesNotAddExtraSelectTags() {
16+
PolicyFactory factory = new HtmlPolicyBuilder()
17+
.allowElements("select", "optgroup", "option")
18+
.allowAttributes("label").globally()
19+
.toFactory();
20+
21+
String input = "<select><optgroup label=\"mygroup\"><option>My option</option></optgroup></select>";
22+
String result = factory.sanitize(input);
23+
24+
// The key assertion: no extra select tags should be inserted
25+
assertEquals(input, result);
26+
}
27+
}

owasp-java-html-sanitizer/src/test/java/org/owasp/html/SanitizersTest.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,30 @@ void testLinks() {
251251
s.sanitize("<a name=\"header\" id=\"header\">Header text</a>"));
252252
}
253253

254+
@Test
255+
void testLinksRelAttributeAdditionsOrder() {
256+
// Issue 336.
257+
PolicyFactory pf = Sanitizers.LINKS.and(
258+
new HtmlPolicyBuilder()
259+
.allowElements("a")
260+
.requireRelsOnLinks("noopener", "noreferrer")
261+
.toFactory());
262+
263+
assertEquals(
264+
"<a href=\"foo.html\" rel=\"nofollow noopener noreferrer\">Link text</a>",
265+
pf.sanitize("<a href=\"foo.html\">Link text</a>"));
266+
267+
pf = Sanitizers.LINKS.and(
268+
new HtmlPolicyBuilder()
269+
.allowElements("a")
270+
.requireRelsOnLinks("noreferrer", "noopener")
271+
.toFactory());
272+
273+
assertEquals(
274+
"<a href=\"foo.html\" rel=\"nofollow noreferrer noopener\">Link text</a>",
275+
pf.sanitize("<a href=\"foo.html\">Link text</a>"));
276+
}
277+
254278
@Test
255279
void testExplicitlyAllowedProtocolsAreCaseInsensitive() {
256280
// Issue 24.
@@ -552,7 +576,7 @@ void testStyleGlobally() {
552576
String want = "<h1 style=\"color:green\">This is some green text</h1>";
553577
assertEquals(want, policyBuilder.sanitize(input));
554578
}
555-
579+
556580
static int fac(int n) {
557581
int ifac = 1;
558582
for (int i = 1; i <= n; ++i) {

0 commit comments

Comments
 (0)