forgejo-federation/services/repository/files
sillyguodong 51ab495198
escape filename when assemble URL (#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: Andrew Thornton <art27@cantab.net>
2023-02-12 09:31:14 +08:00
..
cherry_pick.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
commit.go Use context parameter in models/git (#22367) 2023-01-09 11:50:54 +08:00
content.go escape filename when assemble URL (#22850) 2023-02-12 09:31:14 +08:00
content_test.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
delete.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
diff.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
diff_test.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
file.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
file_test.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
patch.go Refactor git command package to improve security and maintainability (#22678) 2023-02-04 10:30:43 +08:00
temp_repo.go Refactor git command package to improve security and maintainability (#22678) 2023-02-04 10:30:43 +08:00
tree.go Use complete SHA to create and query commit status (#22244) 2022-12-27 21:12:49 +08:00
tree_test.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
update.go Refactor git command package to improve security and maintainability (#22678) 2023-02-04 10:30:43 +08:00
upload.go Refactor git command package to improve security and maintainability (#22678) 2023-02-04 10:30:43 +08:00