forgejo/services
Yarden Shoham 40a09dc1bb
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-17 01:18:05 -07:00
..
agit Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551) 2022-10-24 20:29:17 +01:00
asymkey
attachment Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551) 2022-10-24 20:29:17 +01:00
auth refactor auth interface to return error when verify failure (#22119) (#22259) 2022-12-29 13:50:09 +08:00
automerge
comments
context
cron [PRIVACY] Add a DNS method to fetch new updates 2023-02-11 22:57:55 +01:00
externalaccount
forms Revert unrelated changes for SMTP auth (#21767) (#21768) 2022-11-10 16:11:56 -05:00
gitdiff Refactor git command arguments and make all arguments to be safe to be used (#21535) 2022-10-23 22:44:45 +08:00
issue Fix issue not auto-closing when it includes a reference to a branch (#22514) (#22521) 2023-01-19 11:17:44 -06:00
lfs Prevent Authorization header for presigned LFS urls (#21531) 2022-10-22 21:36:44 +08:00
mailer [BRANDING] add X-Forgejo-* headers 2023-02-12 00:19:58 +01:00
markup Link mentioned user in markdown only if they are visible to viewer (#21554) 2022-10-23 17:13:52 +08:00
migrations Skip GitHub migration tests if the API token is undefined (#21824) 2023-02-11 09:15:02 +01:00
mirror Use proxy for pull mirror (#22771) (#22772) 2023-02-17 01:18:01 -07:00
org Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551) 2022-10-24 20:29:17 +01:00
packages refactor auth interface to return error when verify failure (#22119) (#22259) 2022-12-29 13:50:09 +08:00
pull Load issue before accessing index in merge message (#22822) (#22830) 2023-02-09 16:53:14 -05:00
release Revert "Do not send notifications for draft releases (#21451)" (#21594) 2022-10-26 00:00:00 +02:00
repository escape filename when assemble URL (#22850) (#22871) 2023-02-17 01:18:05 -07:00
task Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551) 2022-10-24 20:29:17 +01:00
user Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551) 2022-10-24 20:29:17 +01:00
webhook [BRANDING] define the forgejo webhook type 2023-02-12 00:19:58 +01:00
wiki Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551) 2022-10-24 20:29:17 +01:00