Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent NPE on partial match of compare URL (part 2) #18490

Closed
Closed
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
5 changes: 4 additions & 1 deletion modules/markup/html.go
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,9 @@ func comparePatternProcessor(ctx *RenderContext, node *html.Node) {
}

// Ensure that every group (m[0]...m[7]) has a match
if len(m) < 8 {
return
}
for i := 0; i < 8; i++ {
if m[i] == -1 {
return
Expand All @@ -959,7 +962,7 @@ func comparePatternProcessor(ctx *RenderContext, node *html.Node) {
text2 := base.ShortSha(node.Data[m[6]:m[7]])

hash := ""
if m[9] > 0 {
if len(m) > 9 && m[9] > 0 {
hash = node.Data[m[8]:m[9]][1:]
}

Expand Down