Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions modules/references/references.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package references

import (
"bytes"
"net/url"
"regexp"
"strconv"
Expand All @@ -14,6 +15,8 @@ import (
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/markup/mdstripper"
"code.gitea.io/gitea/modules/setting"

"github.com/yuin/goldmark/util"
Comment thread
6543 marked this conversation as resolved.
)

var (
Expand Down Expand Up @@ -321,7 +324,7 @@ func FindRenderizableReferenceNumeric(content string, prOnly bool) (bool, *Rende
return false, nil
}
}
r := getCrossReference([]byte(content), match[2], match[3], false, prOnly)
r := getCrossReference(util.StringToReadOnlyBytes(content), match[2], match[3], false, prOnly)
if r == nil {
return false, nil
}
Expand Down Expand Up @@ -465,18 +468,17 @@ func findAllIssueReferencesBytes(content []byte, links []string) []*rawReference
}

func getCrossReference(content []byte, start, end int, fromLink bool, prOnly bool) *rawReference {
refid := string(content[start:end])
sep := strings.IndexAny(refid, "#!")
sep := bytes.IndexAny(content[start:end], "#!")
if sep < 0 {
return nil
}
isPull := refid[sep] == '!'
isPull := content[start+sep] == '!'
if prOnly && !isPull {
return nil
}
repo := refid[:sep]
issue := refid[sep+1:]
index, err := strconv.ParseInt(issue, 10, 64)
repo := string(content[start : start+sep])
issue := string(content[start+sep+1 : end])
index, err := strconv.ParseInt(string(issue), 10, 64)
Comment thread
zeripath marked this conversation as resolved.
if err != nil {
return nil
}
Expand Down