Skip to content

Commit 2163dd5

Browse files
committed
Revert "[UNDERTOW-1875] - add system property to allow ID less matrix parameters"
This reverts commit b7a4122.
1 parent e42373a commit 2163dd5

File tree

3 files changed

+5
-42
lines changed

3 files changed

+5
-42
lines changed

core/src/main/java/io/undertow/UndertowOptions.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -395,19 +395,6 @@ public class UndertowOptions {
395395
*/
396396
public static final Option<Boolean> TRACK_ACTIVE_REQUESTS = Option.simple(UndertowOptions.class, "TRACK_ACTIVE_REQUESTS", Boolean.class);
397397

398-
/**
399-
* Specify if matrix parameters without ID should be allowed or not. If set to 'true' '/test;param1,param2/next-path-segment' will be acceptable.
400-
* (spec compliant '/test;PARAM_ID=param1,param2/next-path-segment')
401-
*
402-
* If this is not specified it will be the same as {@link #DEFAULT_ALLOW_ID_LESS_MATRIX_PARAMETERS}.
403-
*/
404-
public static final Option<Boolean> ALLOW_ID_LESS_MATRIX_PARAMETERS = Option.simple(UndertowOptions.class, "ALLOW_ID_LESS_MATRIX_PARAMETERS", Boolean.class);
405-
406-
/**
407-
* Default value of allow ID-less matrix parameters - false. We should comply with spec.
408-
*/
409-
public static final boolean DEFAULT_ALLOW_ID_LESS_MATRIX_PARAMETERS = false;
410-
411398
private UndertowOptions() {
412399

413400
}

core/src/main/java/io/undertow/server/protocol/http/HttpRequestParser.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ public abstract class HttpRequestParser {
169169
private final String charset;
170170
private final int maxCachedHeaderSize;
171171
private final boolean allowUnescapedCharactersInUrl;
172-
private final boolean allowIDLessMatrixParams;
173172

174173
private static final boolean[] ALLOWED_TARGET_CHARACTER = new boolean[256];
175174

@@ -217,7 +216,6 @@ public HttpRequestParser(OptionMap options) {
217216
charset = options.get(UndertowOptions.URL_CHARSET, StandardCharsets.UTF_8.name());
218217
maxCachedHeaderSize = options.get(UndertowOptions.MAX_CACHED_HEADER_SIZE, UndertowOptions.DEFAULT_MAX_CACHED_HEADER_SIZE);
219218
this.allowUnescapedCharactersInUrl = options.get(UndertowOptions.ALLOW_UNESCAPED_CHARACTERS_IN_URL, false);
220-
this.allowIDLessMatrixParams = options.get(UndertowOptions.ALLOW_ID_LESS_MATRIX_PARAMETERS, UndertowOptions.DEFAULT_ALLOW_ID_LESS_MATRIX_PARAMETERS);
221219
}
222220

223221
public static final HttpRequestParser instance(final OptionMap options) {
@@ -644,7 +642,7 @@ final void handlePathParameters(ByteBuffer buffer, ParseState state, HttpServerE
644642
if (decode && (next == '+' || next == '%' || next > 127)) {
645643
urlDecodeRequired = true;
646644
}
647-
if ((next == '=' || (next == ',' && this.allowIDLessMatrixParams)) && param == null) {
645+
if (next == '=' && param == null) {
648646
param = decode(stringBuilder.substring(pos), urlDecodeRequired, state, true, true);
649647
urlDecodeRequired = false;
650648
pos = stringBuilder.length() + 1;
@@ -670,11 +668,11 @@ final void handlePathParameters(ByteBuffer buffer, ParseState state, HttpServerE
670668
state.nextQueryParam = param;
671669
}
672670

673-
private void handleParsedParam(String paramName, String parameterValue, HttpServerExchange exchange, boolean urlDecodeRequired, ParseState state) throws BadRequestException {
674-
if (paramName == null) {
675-
exchange.addPathParam(decode(parameterValue, urlDecodeRequired, state, true, true), "");
671+
private void handleParsedParam(String previouslyParsedParam, String parsedParam, HttpServerExchange exchange, boolean urlDecodeRequired, ParseState state) throws BadRequestException {
672+
if (previouslyParsedParam == null) {
673+
exchange.addPathParam(decode(parsedParam, urlDecodeRequired, state, true, true), "");
676674
} else { // path param already parsed so parse and add the value
677-
exchange.addPathParam(paramName, decode(parameterValue, urlDecodeRequired, state, true, true));
675+
exchange.addPathParam(previouslyParsedParam, decode(parsedParam, urlDecodeRequired, state, true, true));
678676
}
679677
}
680678

core/src/test/java/io/undertow/server/protocol/http/SimpleParserTestCase.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -383,28 +383,6 @@ public void testServletURLMultiLevelMatrixParameterEndingWithNormalPathAndQuery(
383383
Assert.assertTrue(result.isHostIncludedInRequestURI());
384384
}
385385

386-
@Test
387-
public void testIDLessMatrixParameters() throws BadRequestException {
388-
byte[] in = "GET http://localhost:7777/route/v1/driving/13.388860,52.517037;13.397634,52.529407,111;13.428555,52.523219,222?overview=false HTTP/1.1\r\n\r\n".getBytes();
389-
ParseState context = new ParseState(10);
390-
HttpServerExchange result = new HttpServerExchange(null);
391-
OptionMap.Builder builder = OptionMap.builder()
392-
.set(UndertowOptions.ALLOW_ENCODED_SLASH, true)
393-
.set(UndertowOptions.ALLOW_ID_LESS_MATRIX_PARAMETERS, true);
394-
HttpRequestParser.instance(builder.getMap()).handle(ByteBuffer.wrap(in), context, result);
395-
Assert.assertSame(Methods.GET, result.getRequestMethod());
396-
Assert.assertEquals("http://localhost:7777/route/v1/driving/13.388860,52.517037;13.397634,52.529407,111;13.428555,52.523219,222", result.getRequestURI());
397-
Assert.assertEquals("/route/v1/driving/13.388860,52.517037", result.getRequestPath());
398-
Assert.assertEquals("overview=false", result.getQueryString());
399-
Assert.assertEquals("52.529407", result.getPathParameters().get("13.397634").getFirst());
400-
Assert.assertEquals("111", result.getPathParameters().get("13.397634").getLast());
401-
Assert.assertEquals("52.523219", result.getPathParameters().get("13.428555").getFirst());
402-
Assert.assertEquals("222", result.getPathParameters().get("13.428555").getLast());
403-
Assert.assertEquals("false", result.getQueryParameters().get("overview").getFirst());
404-
Assert.assertSame(Protocols.HTTP_1_1, result.getProtocol());
405-
Assert.assertTrue(result.isHostIncludedInRequestURI());
406-
}
407-
408386
@Test
409387
public void testFullUrlRootPath() throws BadRequestException {
410388
byte[] in = "GET http://myurl.com HTTP/1.1\r\n\r\n".getBytes();

0 commit comments

Comments
 (0)