Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-24 10:46:10 +01:00
forgejo/services/repository/files
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
..
cherry_pick.go Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551) 2022-10-24 20:29:17 +01:00
commit.go Use complete SHA to create and query commit status (#22244) (#22257) 2022-12-28 11:03:21 +01:00
content.go escape filename when assemble URL (#22850) (#22871) 2023-02-12 09:39:52 +00:00
content_test.go Add latest commit's SHA to content response (#20398) 2022-07-30 16:09:04 +08:00
delete.go Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551) 2022-10-24 20:29:17 +01:00
diff.go Propagate context and ensure git commands run in request context (#17868) 2022-01-19 23:26:57 +00:00
diff_test.go Calculate filename hash only once (#19654) 2022-05-09 00:29:50 +02:00
file.go Propagate context and ensure git commands run in request context (#17868) 2022-01-19 23:26:57 +00:00
file_test.go Add latest commit's SHA to content response (#20398) 2022-07-30 16:09:04 +08:00
patch.go Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551) 2022-10-24 20:29:17 +01:00
temp_repo.go Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551) 2022-10-24 20:29:17 +01:00
tree.go Use complete SHA to create and query commit status (#22244) (#22257) 2022-12-28 11:03:21 +01:00
tree_test.go Propagate context and ensure git commands run in request context (#17868) 2022-01-19 23:26:57 +00:00
update.go Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551) 2022-10-24 20:29:17 +01:00
upload.go Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551) 2022-10-24 20:29:17 +01:00