Skip to content

Commit 01f56d9

Browse files
committed
Add missing HttpServerOptions#useSemicolonAsQueryParamDelimiter
Motivation: The new useSemicolonAsQueryParamDelimiter was implemented differently in 5.1 and 4.5.x in terms of configuration. 5.1 was implemented directly in HttpServerConfig and 4.5.x was done on HttpServerOptions. We need to port the HttpServerOptions property to 5.1 and emulate it with the HttpServerConfig. Changes: Add HttpServerOptions#useSemicolonAsQueryParamDelimiter and configure HttpServerConfig#queryParamDecoderConfig accordingly.
1 parent 5d47460 commit 01f56d9

3 files changed

Lines changed: 40 additions & 0 deletions

File tree

vertx-core/src/main/java/io/vertx/core/http/HttpServerConfig.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,16 @@ public HttpServerConfig(HttpServerOptions options) {
124124
.setMaxFields(options.getMaxFormFields())
125125
.setMaxBufferedBytes(options.getMaxFormBufferedBytes());
126126

127+
QueryParamDecoderConfig queryParamDecoderConfig;
128+
if (options.isUseSemicolonAsQueryParamDelimiter() == QueryParamDecoderConfig.DEFAULT_USE_SEMICOLON_AS_DELIMITER) {
129+
queryParamDecoderConfig = null;
130+
} else {
131+
queryParamDecoderConfig = new QueryParamDecoderConfig().setUseSemicolonAsDelimiter(!QueryParamDecoderConfig.DEFAULT_USE_SEMICOLON_AS_DELIMITER);
132+
}
133+
127134
this.versions = versions;
128135
this.formDecoderConfig = formDecoderConfig;
136+
this.queryParamDecoderConfig = queryParamDecoderConfig;
129137
this.handle100ContinueAutomatically = options.isHandle100ContinueAutomatically();
130138
this.strictThreadMode = options.getStrictThreadMode();
131139
this.observabilityConfig = observabilityConfig;

vertx-core/src/main/java/io/vertx/core/http/HttpServerOptions.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ public class HttpServerOptions extends NetServerOptions {
231231
private TimeUnit http2RstFloodWindowDurationTimeUnit;
232232
private boolean strictThreadMode;
233233
private boolean http2ClearTextEnabled;
234+
private boolean useSemicolonAsQueryParamDelimiter;
234235

235236
/**
236237
* Default constructor
@@ -263,6 +264,7 @@ public HttpServerOptions(HttpServerOptions other) {
263264
this.http2RstFloodWindowDurationTimeUnit = other.http2RstFloodWindowDurationTimeUnit;
264265
this.strictThreadMode = other.strictThreadMode;
265266
this.http2ClearTextEnabled = other.http2ClearTextEnabled;
267+
this.useSemicolonAsQueryParamDelimiter = other.useSemicolonAsQueryParamDelimiter;
266268
}
267269

268270
/**
@@ -304,6 +306,7 @@ private void init() {
304306
registerWebSocketWriteHandlers = DEFAULT_REGISTER_WEBSOCKET_WRITE_HANDLERS;
305307
http2RstFloodWindowDurationTimeUnit = DEFAULT_HTTP2_RST_FLOOD_WINDOW_DURATION_TIME_UNIT;
306308
http2ClearTextEnabled = DEFAULT_HTTP2_CLEAR_TEXT_ENABLED;
309+
useSemicolonAsQueryParamDelimiter = QueryParamDecoderConfig.DEFAULT_USE_SEMICOLON_AS_DELIMITER;
307310
}
308311

309312
/**
@@ -927,6 +930,24 @@ public HttpServerOptions setHttp2ClearTextEnabled(boolean http2ClearTextEnabled)
927930
return this;
928931
}
929932

933+
/**
934+
* @return whether to use the semicolon char {@code ;} as a delimiter for query string parameters.
935+
*/
936+
public boolean isUseSemicolonAsQueryParamDelimiter() {
937+
return useSemicolonAsQueryParamDelimiter;
938+
}
939+
940+
/**
941+
* Configure whether to use the semicolon char {@code ;} as a delimiter for query string parameters.
942+
*
943+
* @param useSemicolonAsDelimiter whether to allow semicolon to be used as a delimiter or it is a an actual parameter name or value
944+
* @return a reference to this, so the API can be used fluently
945+
*/
946+
public HttpServerOptions setUseSemicolonAsQueryParamDelimiter(boolean useSemicolonAsDelimiter) {
947+
this.useSemicolonAsQueryParamDelimiter = useSemicolonAsDelimiter;
948+
return this;
949+
}
950+
930951
/**
931952
* @return the default HTTP/2 connection window size
932953
*/

vertx-core/src/test/java/io/vertx/tests/http/HttpServerConfigTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,15 @@ public void testCompressionFromDefaultOptions() {
4242
}
4343
}
4444
}
45+
46+
@Test
47+
public void testUseSemicolonAsQueryParamDelimiter() {
48+
HttpServerConfig cfg = new HttpServerConfig(new HttpServerOptions());
49+
assertNull(cfg.getQueryParamConfig());
50+
cfg = new HttpServerConfig(new HttpServerOptions().setUseSemicolonAsQueryParamDelimiter(true));
51+
assertNull(cfg.getQueryParamConfig());
52+
cfg = new HttpServerConfig(new HttpServerOptions().setUseSemicolonAsQueryParamDelimiter(false));
53+
assertNotNull(cfg.getQueryParamConfig());
54+
assertFalse(cfg.getQueryParamConfig().isUseSemicolonAsDelimiter());
55+
}
4556
}

0 commit comments

Comments
 (0)