Skip to content

Commit 07e37c8

Browse files
committed
docs(core): clarify raw request path vs normalized path usage
Signed-off-by: MatthaiosStavrou <m_stauroy@hotmail.com>
1 parent 970dc22 commit 07e37c8

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

vertx-core/src/main/asciidoc/http.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,14 @@ For example, if the request URI was `a/b/c/page.html?param1=abc&param2=xyz
187187

188188
Then the path would be `/a/b/c/page.html`
189189

190+
Note that `HttpServerRequest#path()` returns the raw path as it was sent by the client.
191+
This value may contain repeated separators such as `//` or path traversal markers like `..`.
192+
193+
If you are using Vert.x Web and need to perform security-sensitive checks or route
194+
comparisons based on a normalized version of the path, prefer using
195+
`RoutingContext#normalizedPath()` instead. Vert.x Web applies additional
196+
transformations to ensure the path is canonicalized before matching routes.
197+
190198
==== Request query
191199

192200
Use {@link io.vertx.core.http.HttpServerRequest#query} to return the query part of the URI

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,16 @@ public interface HttpRequestHead {
2828
String uri();
2929

3030
/**
31-
* @return The path part of the uri. For example {@code /somepath/somemorepath/someresource.foo}
31+
* Returns the path component of the HTTP request URI.
32+
* <p>
33+
* This is the raw, non-normalized path as received from the client.
34+
* It may contain duplicated separators or traversal segments such as {@code ".."}.
35+
* <p>
36+
* For security-sensitive logic (for example access control, routing or
37+
* filesystem checks), applications should prefer using a normalized path
38+
* provided by the framework instead of relying on this raw value.
39+
*
40+
* @return the raw path component of the request URI
3241
*/
3342
@Nullable
3443
String path();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ default boolean canUpgradeToWebSocket() {
395395
* @return the priority of the associated HTTP/2 stream for HTTP/2 otherwise {@code null}
396396
*/
397397
default StreamPriority streamPriority() {
398-
return null;
398+
return null;
399399
}
400400

401401
/**

0 commit comments

Comments
 (0)