From a0265d2e6b258b7cf13b53534c57a007ae0a3867 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Fri, 28 Apr 2023 10:24:17 +0800 Subject: [PATCH] fix: permalink of singlePage cannot contain special characters (#3867) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /kind bug /area core /milestone 2.5.x #### What this PR does / why we need it: 修复页面的链接不能包含特殊字符的问题。 #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/3808 #### Special notes for your reviewer: 测试方式: 1. 创建一个页面。 2. 尝试设置别名为中文或者其他字符。 3. 尝试包含多个 `/` 分隔符。 4. 尝试访问页面,检查是否能够正常访问。 #### Does this PR introduce a user-facing change? ```release-note 修复页面链接包含中文等字符后无法访问的问题。 ``` --- .../main/java/run/halo/app/theme/router/SinglePageRoute.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/application/src/main/java/run/halo/app/theme/router/SinglePageRoute.java b/application/src/main/java/run/halo/app/theme/router/SinglePageRoute.java index eddbddbad..805d45ffe 100644 --- a/application/src/main/java/run/halo/app/theme/router/SinglePageRoute.java +++ b/application/src/main/java/run/halo/app/theme/router/SinglePageRoute.java @@ -1,8 +1,6 @@ package run.halo.app.theme.router; -import static java.nio.charset.StandardCharsets.UTF_8; import static org.springframework.web.reactive.function.server.RequestPredicates.GET; -import static org.springframework.web.util.UriUtils.encodePath; import java.util.HashMap; import java.util.List; @@ -119,8 +117,7 @@ public class SinglePageRoute } String singlePageRoute(String slug) { - var permalink = encodePath(slug, UTF_8); - return StringUtils.prependIfMissing(permalink, "/"); + return StringUtils.prependIfMissing(slug, "/"); } HandlerFunction handlerFunction(String name) {