diff options
author | Gusted <williamzijl7@hotmail.com> | 2022-07-07 17:46:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-07 17:46:49 +0200 |
commit | 3f513f9e54970ee1f3443edbe77077ff62dbd018 (patch) | |
tree | b13bb0c749f33dc886db6b56d90ec27c87d4a84b | |
parent | 970288f0b234abd34c8499df108dfe9cbe439315 (diff) | |
download | gitea-3f513f9e54970ee1f3443edbe77077ff62dbd018.tar.gz gitea-3f513f9e54970ee1f3443edbe77077ff62dbd018.zip |
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
-rw-r--r-- | modules/markup/html.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/modules/markup/html.go b/modules/markup/html.go index 69d9ba3ef2..6071180501 100644 --- a/modules/markup/html.go +++ b/modules/markup/html.go @@ -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 } |