You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This was raised as an issue in Quarkus, here quarkusio/quarkus#10177. However, looking into the details, it turns out to be an issue in vertx-web project.
If the request URI path contains special character like [, any calls to HttpServerRequest.absoluteURI will (internally) run into a URI parsing exception (which is only logged) and the method ends up returning null.
Here's a test case which reproduces this against the latest 3.9 branch:
diff --git a/vertx-web/src/test/java/io/vertx/ext/web/handler/HttpRequestPathTest.java b/vertx-web/src/test/java/io/vertx/ext/web/handler/HttpRequestPathTest.java
new file mode 100644
index 00000000..b1b05628
--- /dev/null
+++ b/vertx-web/src/test/java/io/vertx/ext/web/handler/HttpRequestPathTest.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2020 Red Hat, Inc.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Apache License v2.0 which accompanies this distribution.
+ *
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * The Apache License v2.0 is available at
+ * http://www.opensource.org/licenses/apache2.0.php
+ *
+ * You may elect to redistribute this code under either of these licenses.
+ */
+
+package io.vertx.ext.web.handler;
+
+import io.vertx.core.http.HttpMethod;
+import io.vertx.ext.web.WebTestBase;
+import org.junit.Test;
+
+public class HttpRequestPathTest extends WebTestBase {
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+
+ }
+
+ @Test
+ public void testSpecialCharAbsoluteURI() throws Exception {
+ router.route().handler((rc) -> {
+ final String absoluteURI = rc.request().absoluteURI();
+ if (absoluteURI == null) {
+ throw new RuntimeException("Absolute URI was null");
+ }
+ rc.next();
+ });
+ router.route().handler(rc -> rc.response().end());
+ testSyncRequest("GET", "/[hello", 200, "OK", "");
+ }
+
+}
This test run results in the following log messages and the failure:
Failed to create abs uri
java.net.URISyntaxException: Illegal character in path at index 1: /[hello
at java.base/java.net.URI$Parser.fail(URI.java:2915)
at java.base/java.net.URI$Parser.checkChars(URI.java:3086)
at java.base/java.net.URI$Parser.parseHierarchical(URI.java:3168)
at java.base/java.net.URI$Parser.parse(URI.java:3127)
at java.base/java.net.URI.<init>(URI.java:600)
at io.vertx.core.http.impl.HttpUtils.absoluteURI(HttpUtils.java:366)
at io.vertx.core.http.impl.HttpServerRequestImpl.absoluteURI(HttpServerRequestImpl.java:370)
at io.vertx.ext.web.impl.HttpServerRequestWrapper.absoluteURI(HttpServerRequestWrapper.java:210)
at io.vertx.ext.web.handler.HttpRequestPathTest.lambda$testSpecialCharAbsoluteURI$0(HttpRequestPathTest.java:34)
...
java.lang.AssertionError: expected:<200> but was:<500>
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.failNotEquals(Assert.java:834)
at org.junit.Assert.assertEquals(Assert.java:645)
at org.junit.Assert.assertEquals(Assert.java:631)
at io.vertx.test.core.AsyncTestBase.assertEquals(AsyncTestBase.java:235)
at io.vertx.ext.web.WebTestBase.testSyncRequest(WebTestBase.java:196)
at io.vertx.ext.web.handler.HttpRequestPathTest.testSpecialCharAbsoluteURI(HttpRequestPathTest.java:41)
The text was updated successfully, but these errors were encountered:
brackets should be url encoded if i'm not mistaken. Also this isn't reproducible on master, in order to fix it we need to apply on core what we now do on web.
This was raised as an issue in Quarkus, here quarkusio/quarkus#10177. However, looking into the details, it turns out to be an issue in vertx-web project.
If the request URI path contains special character like
[
, any calls toHttpServerRequest.absoluteURI
will (internally) run into a URI parsing exception (which is only logged) and the method ends up returningnull
.Here's a test case which reproduces this against the latest
3.9
branch:This test run results in the following log messages and the failure:
The text was updated successfully, but these errors were encountered: