[x]):Every time I have a directory name with a space and try to use markdown links, gitea change the space to '+' instead of '%20' and it gives 404.
...
Original Markdown

Render OK

BAD Link (directory with space)

I have included screenshots to exemplify the error.
This is because of:
urlPrefix in this case will be /heliomcp/testes/src/branch/master/Teste+A
Which will be used here to generate the link:
Then the link itself fails because it looks for Teste+A here:
and fails
2020/02/14 19:07:38 routers/repo/view.go:506:renderCode() [E] Repo.Commit.GetTreeEntryByPath: object does not exist [id: , rel_path: Teste+A]
/Users/mrsdizzie/.go/src/code.gitea.io/gitea/routers/repo/view.go:506 (0x535b3e8)
renderCode: ctx.NotFoundOrServerError("Repo.Commit.GetTreeEntryByPath", git.IsErrNotExist, err)
/Users/mrsdizzie/.go/src/code.gitea.io/gitea/routers/repo/view.go:441 (0x535a021)
Home: renderCode(ctx)
So while a + might be considered valid for the URL it is then being used literally when trying to get the tree entry and fails because there is no path of Teste+A
And source of blank space being converted into a + for ctx.urlPrefix is:
So I assume this never worked and isn't related to switching to goldmark. @zeripath -- should we just be be replacing a blank space with %20 when rendering markdown here instead of a +? Just tagging you since you did a lot with the markdown code recently.
I see we do this strings.Replace(var, " ", "+", -1) a couple of places but seems like it should be %20 if those strings are also going to be used for looking at files on disk
That should work.
OK I'll think on it a bit more and do a PR to fix this then
Most helpful comment
This is because of:
https://github.com/go-gitea/gitea/blob/a97fe76950bf69ca71c9b790e8d0e76d5e870235/modules/markup/markdown/markdown.go#L33-L38
urlPrefix in this case will be
/heliomcp/testes/src/branch/master/Teste+AWhich will be used here to generate the link:
https://github.com/go-gitea/gitea/blob/a97fe76950bf69ca71c9b790e8d0e76d5e870235/modules/markup/markdown/goldmark.go#L69-L87
Then the link itself fails because it looks for
Teste+Ahere:https://github.com/go-gitea/gitea/blob/a97fe76950bf69ca71c9b790e8d0e76d5e870235/routers/repo/view.go#L503-L508
and fails
So while a
+might be considered valid for the URL it is then being used literally when trying to get the tree entry and fails because there is no path of Teste+AAnd source of blank space being converted into a + for ctx.urlPrefix is:
https://github.com/go-gitea/gitea/blob/a97fe76950bf69ca71c9b790e8d0e76d5e870235/modules/markup/markup.go#L83-L92
So I assume this never worked and isn't related to switching to goldmark. @zeripath -- should we just be be replacing a blank space with %20 when rendering markdown here instead of a +? Just tagging you since you did a lot with the markdown code recently.
I see we do this strings.Replace(var, " ", "+", -1) a couple of places but seems like it should be %20 if those strings are also going to be used for looking at files on disk