Skip to content

Commit

Permalink
Fix NPE when using non-numeric
Browse files Browse the repository at this point in the history
- This code is only valid when `refNumeric` exist(otherwise we didn't find
such numeric PR and can skip that check) and give a free-pas to the  "BEFORE" check when
`ref` is nil.
- Resolves go-gitea#20109
  • Loading branch information
Gusted committed Jul 7, 2022
1 parent 6efbe49 commit 226f62b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions modules/markup/html.go
Original file line number Diff line number Diff line change
Expand Up @@ -841,9 +841,10 @@ func issueIndexPatternProcessor(ctx *RenderContext, node *html.Node) {

// Repos with external issue trackers might still need to reference local PRs
// We need to concern with the first one that shows up in the text, whichever it is
if hasExtTrackFormat && !isNumericStyle {
if hasExtTrackFormat && !isNumericStyle && refNumeric != nil {
// If numeric (PR) was found, and it was BEFORE the non-numeric pattern, use that
if foundNumeric && refNumeric.RefLocation.Start < ref.RefLocation.Start {
// Allow a free-pass when non-numeric pattern wasn't found.
if found && (ref == nil || refNumeric.RefLocation.Start < ref.RefLocation.Start) {
found = foundNumeric
ref = refNumeric
}
Expand Down

0 comments on commit 226f62b

Please sign in to comment.