1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-12-23 17:53:10 +00:00

Fix crash in short link processor (#13839)

Fixes #13819
This commit is contained in:
mrsdizzie 2020-12-03 21:01:42 -05:00 committed by GitHub
parent c9effd5364
commit 3512c7e40f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -651,6 +651,7 @@ func shortLinkProcessorFull(ctx *postProcessCtx, node *html.Node, noLink bool) {
// When parsing HTML, x/net/html will change all quotes which are
// not used for syntax into UTF-8 quotes. So checking val[0] won't
// be enough, since that only checks a single byte.
if len(val) > 1 {
if (strings.HasPrefix(val, "“") && strings.HasSuffix(val, "”")) ||
(strings.HasPrefix(val, "") && strings.HasSuffix(val, "")) {
const lenQuote = len("")
@ -662,6 +663,7 @@ func shortLinkProcessorFull(ctx *postProcessCtx, node *html.Node, noLink bool) {
const lenQuote = len("")
val = val[1 : len(val)-lenQuote]
}
}
props[key] = val
}
}