halo/application
John Niang 43f41c3fc2
Handle invalid characters in permalink URI construction (#7788)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.22.x

#### What this PR does / why we need it:

This PR fixes invalid characters in permalink URI construction.

```java
java.lang.IllegalArgumentException: Invalid character ' ' for PATH in "/upload/2021/04/Web 14ecd358cce14f9f9ca0fa7a1716b5d8.pdf"
	at org.springframework.web.util.HierarchicalUriComponents.verifyUriComponent(HierarchicalUriComponents.java:422) ~[spring-web-6.2.11.jar:6.2.11]
	at org.springframework.web.util.HierarchicalUriComponents$FullPathComponent.verify(HierarchicalUriComponents.java:922) ~[spring-web-6.2.11.jar:6.2.11]
	at org.springframework.web.util.HierarchicalUriComponents.verify(HierarchicalUriComponents.java:386) ~[spring-web-6.2.11.jar:6.2.11]
	at org.springframework.web.util.HierarchicalUriComponents.<init>(HierarchicalUriComponents.java:146) ~[spring-web-6.2.11.jar:6.2.11]
	at org.springframework.web.util.UriComponentsBuilder.buildInternal(UriComponentsBuilder.java:346) ~[spring-web-6.2.11.jar:6.2.11]
	at org.springframework.web.util.UriComponentsBuilder.build(UriComponentsBuilder.java:334) ~[spring-web-6.2.11.jar:6.2.11]
	at run.halo.app.core.attachment.endpoint.LocalAttachmentUploadHandler.doGetPermalink(LocalAttachmentUploadHandler.java:296) ~[classes/:2.22.0-SNAPSHOT]
	at run.halo.app.core.attachment.endpoint.LocalAttachmentUploadHandler.getPermalink(LocalAttachmentUploadHandler.java:266) ~[classes/:2.22.0-SNAPSHOT]
	at run.halo.app.core.user.service.impl.DefaultAttachmentService.lambda$getPermalink$12(DefaultAttachmentService.java:128) ~[classes/:2.22.0-SNAPSHOT]
```

#### Does this PR introduce a user-facing change?

```release-note
修复可能无法正常获取附件链接的问题
```
2025-10-02 05:06:25 +00:00
..
libs Fix the problem of memory leak caused by thymeleaf (#7678) 2025-08-12 10:46:48 +00:00
src Handle invalid characters in permalink URI construction (#7788) 2025-10-02 05:06:25 +00:00
build.gradle Set dynamic branch name for Docker image tags in build.gradle (#7780) 2025-09-24 12:17:33 +08:00