mirror of
1
Fork 0
forgejo/services/repository
Yarden Shoham 43d1183f67
escape filename when assemble URL (#22850) (#22871)
Backport #22850

Fixes: #22843 

### Cause:

affdd40296/services/repository/files/content.go (L161)

Previously, we did not escape the **"%"** that might be in "treePath"
when call "url.parse()".


![image](https://user-images.githubusercontent.com/33891828/218066318-5a909e50-2a17-46e6-b32f-684b2aa4b91f.png)

This function will check whether "%" is the beginning of an escape
character. Obviously, the "%" in the example (hello%mother.txt) is not
that. So, the function will return a error.

### Solution:
We can escape "treePath" by call "url.PathEscape()" function firstly.

### Screenshot:

![image](https://user-images.githubusercontent.com/33891828/218069781-1a030f8b-18d0-4804-b0f8-73997849ef43.png)

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: sillyguodong <33891828+sillyguodong@users.noreply.github.com>
Co-authored-by: Andrew Thornton <art27@cantab.net>
2023-02-12 09:39:52 +00:00
..
archiver Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551) 2022-10-24 20:29:17 +01:00
files escape filename when assemble URL (#22850) (#22871) 2023-02-12 09:39:52 +00:00
adopt.go Do not list active repositories as unadopted (#22034) (#22166) 2022-12-19 12:48:38 +00:00
adopt_test.go Fix repository adoption on Windows (#21646) (#21650) 2022-11-01 22:32:03 +00:00
avatar.go Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551) 2022-10-24 20:29:17 +01:00
avatar_test.go Refactor AssertExistsAndLoadBean to use generics (#20797) 2022-08-16 10:22:25 +08:00
branch.go Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551) 2022-10-24 20:29:17 +01:00
cache.go Slightly simplify LastCommitCache (#20444) 2022-07-25 16:39:42 +01:00
check.go Continue GCing other repos on error in one repo (#22422) (#22425) 2023-01-13 15:29:16 -06:00
fork.go Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551) 2022-10-24 20:29:17 +01:00
fork_test.go Move some files into models' sub packages (#20262) 2022-08-25 10:31:57 +08:00
hooks.go Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551) 2022-10-24 20:29:17 +01:00
main_test.go Use a struct as test options (#19393) 2022-04-14 21:58:21 +08:00
push.go When updating by rebase we need to set the environment for head repo (#22535) (#22536) 2023-01-19 17:31:20 -05:00
repository.go Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551) 2022-10-24 20:29:17 +01:00
repository_test.go Move some repository related code into sub package (#19711) 2022-06-06 16:01:49 +08:00
review.go Move some repository related code into sub package (#19711) 2022-06-06 16:01:49 +08:00
review_test.go Refactor AssertExistsAndLoadBean to use generics (#20797) 2022-08-16 10:22:25 +08:00
template.go Remove manual rollback for failed generated repositories (#20639) 2022-08-09 17:41:52 +08:00
transfer.go Move some files into models' sub packages (#20262) 2022-08-25 10:31:57 +08:00
transfer_test.go Move some files into models' sub packages (#20262) 2022-08-25 10:31:57 +08:00