Skip to content

Commit a99f117

Browse files
committed
XMLHttpRequest open('trace', ...) throws a security error
1 parent 01e9137 commit a99f117

3 files changed

Lines changed: 182 additions & 75 deletions

File tree

src/changes/changes.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88

99
<body>
1010
<release version="5.0.0" date="April 01, 2026" description="jdk17, Bugfixes">
11+
<action type="fix" dev="rbri">
12+
XMLHttpRequest open('trace', ...) throws a security error.
13+
</action>
14+
<action type="update" dev="RhinoTeam">
15+
The test suite now uses Jetty 12.1.
16+
</action>
1117
<action type="update" dev="rbri">
1218
INCOMPATIBLE CHANGE: Cookie moved from package 'org.htmlunit.util' to 'org.htmlunit.http'
1319
</action>

src/main/java/org/htmlunit/javascript/host/xml/XMLHttpRequest.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,8 +680,16 @@ public void open(final String method, final Object urlParam, final Object asyncP
680680
request.setDefaultResponseContentCharset(UTF_8);
681681
request.setRefererHeader(pageUrl);
682682

683+
final String methodUC = method.toUpperCase(Locale.ROOT);
684+
if ("TRACE".equals(methodUC)) {
685+
throw JavaScriptEngine.asJavaScriptException(
686+
getWindow(),
687+
"HTTP Method '" + method + "' not allowed.",
688+
DOMException.SECURITY_ERR);
689+
}
690+
683691
try {
684-
request.setHttpMethod(HttpMethod.valueOf(method.toUpperCase(Locale.ROOT)));
692+
request.setHttpMethod(HttpMethod.valueOf(methodUC));
685693
}
686694
catch (final IllegalArgumentException e) {
687695
if (LOG.isInfoEnabled()) {

0 commit comments

Comments
 (0)