Merge pull request #703 from zznty/dev

[FIX] Fix resolution of files with special characters for embedded file server
This commit is contained in:
microwin7 2024-03-12 17:06:25 +03:00 committed by GitHub
commit 3e6af5afd3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -14,6 +14,8 @@
import java.io.RandomAccessFile;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Clock;
@ -186,7 +188,7 @@ public void channelRead0(ChannelHandlerContext ctx, FullHttpRequest request) thr
final String path;
try {
path = Paths.get(new URI(uri).getPath()).normalize().toString().substring(1);
path = Paths.get(new URI(URLEncoder.encode(uri, StandardCharsets.UTF_8)).getPath()).normalize().toString().substring(1);
} catch (URISyntaxException e) {
sendError(ctx, BAD_REQUEST);
return;