mirror of
https://github.com/russross/blackfriday.git
synced 2024-03-22 13:40:34 +08:00
fix index out of range panic in reference link
Add checking before accessing the input data. Fix #172 and #173 issues. Signed-off-by: Tw <tw19881113@gmail.com>
This commit is contained in:
parent
54d3f20b5c
commit
d28de22ef0
|
@ -541,7 +541,7 @@ func isReference(p *parser, data []byte, tabSize int) int {
|
|||
}
|
||||
i++
|
||||
if p.flags&EXTENSION_FOOTNOTES != 0 {
|
||||
if data[i] == '^' {
|
||||
if i < len(data) && data[i] == '^' {
|
||||
// we can set it to anything here because the proper noteIds will
|
||||
// be assigned later during the second pass. It just has to be != 0
|
||||
noteId = 1
|
||||
|
@ -631,6 +631,9 @@ func scanLinkRef(p *parser, data []byte, i int) (linkOffset, linkEnd, titleOffse
|
|||
for i < len(data) && data[i] != ' ' && data[i] != '\t' && data[i] != '\n' && data[i] != '\r' {
|
||||
i++
|
||||
}
|
||||
if i == len(data) {
|
||||
return
|
||||
}
|
||||
linkEnd = i
|
||||
if data[linkOffset] == '<' && data[linkEnd-1] == '>' {
|
||||
linkOffset++
|
||||
|
|
Loading…
Reference in New Issue
Block a user