Skip to content

Commit 3f513f9

Browse files
author
Gusted
authored
Fix NPE when using non-numeric (#20277)
- 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 #20109
1 parent 970288f commit 3f513f9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

modules/markup/html.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -841,9 +841,10 @@ func issueIndexPatternProcessor(ctx *RenderContext, node *html.Node) {
841841

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

0 commit comments

Comments
 (0)