Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-03-08 22:10:19 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-03-08 23:50:21 +0300
commit53a6210d82eaa2cff7c802df88ff08dac5e7dced (patch)
treebc393f3dc7646e7200e2a03f6e54aa474ce836fe /hugolib
parent7182809d96a1decf937074556ef9f6370b145c4f (diff)
markup/goldmark/codeblocks: Fix slice bounds out of range
For the Position in code blocks we try to match the .Inner with the original source. This isn't always possible. This commits avoids panics in these situations. Fixes #9627
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/page.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/hugolib/page.go b/hugolib/page.go
index 175e1fc3b..c4f30de9d 100644
--- a/hugolib/page.go
+++ b/hugolib/page.go
@@ -784,6 +784,11 @@ func (p *pageState) posFromPage(offset int) text.Position {
}
func (p *pageState) posFromInput(input []byte, offset int) text.Position {
+ if offset < 0 {
+ return text.Position{
+ Filename: p.pathOrTitle(),
+ }
+ }
lf := []byte("\n")
input = input[:offset]
lineNumber := bytes.Count(input, lf) + 1