Skip to content

Commit a95f057

Browse files
NETWORK: Remove Dead Code from Netty4CorsConfig (#34947)
* Same as #34324 for the Netty transport, the `isNullOriginAllowed` setting is always false
1 parent 0fbb8a1 commit a95f057

File tree

3 files changed

+0
-25
lines changed

3 files changed

+0
-25
lines changed

modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/cors/Netty4CorsConfig.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ public final class Netty4CorsConfig {
4848
private final long maxAge;
4949
private final Set<HttpMethod> allowedRequestMethods;
5050
private final Set<String> allowedRequestHeaders;
51-
private final boolean allowNullOrigin;
5251
private final Map<CharSequence, Callable<?>> preflightHeaders;
5352
private final boolean shortCircuit;
5453

@@ -61,7 +60,6 @@ public final class Netty4CorsConfig {
6160
maxAge = builder.maxAge;
6261
allowedRequestMethods = builder.requestMethods;
6362
allowedRequestHeaders = builder.requestHeaders;
64-
allowNullOrigin = builder.allowNullOrigin;
6563
preflightHeaders = builder.preflightHeaders;
6664
shortCircuit = builder.shortCircuit;
6765
}
@@ -108,19 +106,6 @@ public boolean isOriginAllowed(final String origin) {
108106
return false;
109107
}
110108

111-
/**
112-
* Web browsers may set the 'Origin' request header to 'null' if a resource is loaded
113-
* from the local file system.
114-
*
115-
* If isNullOriginAllowed is true then the server will response with the wildcard for the
116-
* the CORS response header 'Access-Control-Allow-Origin'.
117-
*
118-
* @return {@code true} if a 'null' origin should be supported.
119-
*/
120-
public boolean isNullOriginAllowed() {
121-
return allowNullOrigin;
122-
}
123-
124109
/**
125110
* Determines if credentials are supported for CORS requests.
126111
*

modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/cors/Netty4CorsConfigBuilder.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ public static Netty4CorsConfigBuilder forOrigins(final String... origins) {
7474
Optional<Set<String>> origins;
7575
Optional<Pattern> pattern;
7676
final boolean anyOrigin;
77-
boolean allowNullOrigin;
7877
boolean enabled = true;
7978
boolean allowCredentials;
8079
long maxAge;

modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/cors/Netty4CorsHandler.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,6 @@ private void setPreflightHeaders(final HttpResponse response) {
167167
private boolean setOrigin(final HttpResponse response) {
168168
final String origin = request.headers().get(HttpHeaderNames.ORIGIN);
169169
if (!Strings.isNullOrEmpty(origin)) {
170-
if ("null".equals(origin) && config.isNullOriginAllowed()) {
171-
setAnyOrigin(response);
172-
return true;
173-
}
174-
175170
if (config.isAnyOriginSupported()) {
176171
if (config.isCredentialsAllowed()) {
177172
echoRequestOrigin(response);
@@ -201,10 +196,6 @@ private boolean validateOrigin() {
201196
return true;
202197
}
203198

204-
if ("null".equals(origin) && config.isNullOriginAllowed()) {
205-
return true;
206-
}
207-
208199
// if the origin is the same as the host of the request, then allow
209200
if (isSameOrigin(origin, request.headers().get(HttpHeaderNames.HOST))) {
210201
return true;

0 commit comments

Comments
 (0)