forgejo/modules
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
..
actions
activitypub Add Chef package registry (#22554) 2023-02-06 09:49:21 +08:00
analyze
auth Map OIDC groups to Orgs/Teams (#21441) 2023-02-08 14:44:42 +08:00
avatar
base
cache
charset Fix isAllowed of escapeStreamer (#22814) 2023-02-09 20:51:36 +08:00
container
context Fix improper HTMLURL usages in Go code (#22839) 2023-02-11 14:34:11 +08:00
csv
doctor
emoji
eventsource
generate
git Use proxy for pull mirror (#22771) 2023-02-11 08:39:50 +08:00
gitgraph Refactor git command package to improve security and maintainability (#22678) 2023-02-04 10:30:43 +08:00
graceful
hcaptcha
highlight
hostmatcher
html
httpcache
httplib
indexer
issue/template
json
lfs escape filename when assemble URL (#22850) 2023-02-12 09:31:14 +08:00
log
markup
mcaptcha
metrics include build info in Prometheus metrics (#22819) 2023-02-08 19:54:01 +02:00
migration Fix restore repo bug, clarify the problem of ForeignIndex (#22776) 2023-02-07 09:18:52 +08:00
mirror
nosql
notification
options
packages Use import of OCI structs (#22765) 2023-02-06 10:07:09 +00:00
paginator
password
pprof
private
process
proxy Use proxy for pull mirror (#22771) 2023-02-11 08:39:50 +08:00
proxyprotocol
public
queue
recaptcha
references
regexplru
repository Map OIDC groups to Orgs/Teams (#21441) 2023-02-08 14:44:42 +08:00
secret
session
setting Add Chef package registry (#22554) 2023-02-06 09:49:21 +08:00
sitemap
ssh
storage
structs change org_type.go to visible_type.go and fix the notes (#22752) 2023-02-09 06:40:34 +00:00
svg
sync
system
templates Fix more HTMLURL in templates (#22831) 2023-02-09 11:31:30 -05:00
test
timeutil
translation
turnstile Add new captcha: cloudflare turnstile (#22369) 2023-02-05 15:29:03 +08:00
typesniffer
updatechecker
upload
uri
user
util Add Chef package registry (#22554) 2023-02-06 09:49:21 +08:00
validation Map OIDC groups to Orgs/Teams (#21441) 2023-02-08 14:44:42 +08:00
watcher
web Map OIDC groups to Orgs/Teams (#21441) 2023-02-08 14:44:42 +08:00
webhook