1
1
mirror of https://github.com/go-gitea/gitea synced 2024-12-25 18:14:28 +00:00

Don't manually replace whitespace during render (#10291) (#10315)

* Don't manually replace whitespace during render

For historical reasons Gitea manually alters the urlPrefix and replaces
a whitespace with a +. This Works for URLs, but we're also passing
urlPrefix to git calls and adding the + is breaking the tree path.

Goldmark will automatically convert a white space to the proper %20, so
we should leave the string as is which lets us pass it to git unmodified
and then let Goldmark fix it.

Also fixed separate bug in URLJoin I noticed while testing where it will
silently discard sections of a path that have # in them (possibly
others). We should just escape it first.

Fixes 10156

* Escape elems as well

* Revert "Escape elems as well"

This reverts commit 8bf49596fe.

* restart ci

* remove changes to URLJoin

* restart ci

Co-authored-by: techknowlogick <matti@mdranta.net>

Co-authored-by: techknowlogick <matti@mdranta.net>
This commit is contained in:
mrsdizzie 2020-02-17 12:46:28 -05:00 committed by GitHub
parent ff24f81a05
commit 4529a262c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 2 deletions

View File

@ -52,7 +52,6 @@ func (g *GiteaASTTransformer) Transform(node *ast.Document, reader text.Reader,
lnk := string(link) lnk := string(link)
lnk = giteautil.URLJoin(prefix, lnk) lnk = giteautil.URLJoin(prefix, lnk)
lnk = strings.Replace(lnk, " ", "+", -1)
link = []byte(lnk) link = []byte(lnk)
} }
v.Destination = link v.Destination = link

View File

@ -81,7 +81,6 @@ func RenderWiki(filename string, rawBytes []byte, urlPrefix string, metas map[st
} }
func render(parser Parser, rawBytes []byte, urlPrefix string, metas map[string]string, isWiki bool) []byte { func render(parser Parser, rawBytes []byte, urlPrefix string, metas map[string]string, isWiki bool) []byte {
urlPrefix = strings.Replace(urlPrefix, " ", "+", -1)
result := parser.Render(rawBytes, urlPrefix, metas, isWiki) result := parser.Render(rawBytes, urlPrefix, metas, isWiki)
// TODO: one day the error should be returned. // TODO: one day the error should be returned.
result, err := PostProcess(result, urlPrefix, metas, isWiki) result, err := PostProcess(result, urlPrefix, metas, isWiki)