eclipse-vertx / vert.x

Vert.x is a tool-kit for building reactive applications on the JVM
http://vertx.io
Other
14.31k stars 2.08k forks source link

unterminated escape sequence at index xx , failure (400) #4505

Open wbkys opened 2 years ago

wbkys commented 2 years ago

Questions

An error will occur if the http request parameter contains %

Version

vertx-web-4.3.2 Which version(s) did you encounter this bug ?

Context

I encountered an exception which looks suspicious while ...

Do you have a reproducer?

A reproducer is a simple project hosted on GitHub (or another forge supporting git clone operation) that has a build file that can be executed to reproduce the issue.

Reproducers are very helpful for contributors and will likely help them fixing your bug faster.

Steps to reproduce

image

`public class MainVerticle extends AbstractVerticle {

@Override public void start(Promise startPromise) throws Exception { Router router = Router.router(vertx); router.get("/v1").handler(this::test); vertx.createHttpServer().requestHandler(req -> { req.response() .putHeader("content-type", "text/plain") .end("Hello from Vert.x!"); }).listen(8888, http -> { if (http.succeeded()) { startPromise.complete(); System.out.println("HTTP server started on port 8888"); } else { startPromise.fail(http.cause()); } }); }

private void test(RoutingContext rout) { String aa = rout.queryParam("t").isEmpty() ? null : rout.queryParam("t").get(0); } }`

get 127.0.0.1:8888/v1?t=a% echo error 400

Extra

wbkys commented 2 years ago

Occurs when an interface address is entered in the address bar

vietj commented 2 years ago

can you reproduce from curl ?

wbkys commented 2 years ago

can you reproduce from curl ?

未命名1665472437

wbkys commented 2 years ago

image The problem occurs in the method rout.queryParam

wbkys commented 2 years ago

io.vertx.ext.web.impl.RoutingContextImpl => private MultiMap getQueryParams(Charset charset) => io.netty.handler.codec.http.QueryStringDecoder => private static String decodeComponent(String s, int from, int toExcluded, Charset charset, boolean isPath) image %Symbol judgment is too simple