Fix ExplicitLineBreak parsing
fuzzed index out of range and moved range check into for condition as \\ followed by spaces at the end of the inline text should not be turned into an ExplicitLineBreak (just like \\ not followed by spaces).
This commit is contained in:
parent
14900e97e2
commit
4292628c80
4 changed files with 18 additions and 4 deletions
|
@ -147,8 +147,8 @@ func (d *Document) parseExplicitLineBreakOrLatexFragment(input string, start int
|
||||||
switch {
|
switch {
|
||||||
case start+2 >= len(input):
|
case start+2 >= len(input):
|
||||||
case input[start+1] == '\\' && start != 0 && input[start-1] != '\n':
|
case input[start+1] == '\\' && start != 0 && input[start-1] != '\n':
|
||||||
for i := start + 2; unicode.IsSpace(rune(input[i])); i++ {
|
for i := start + 2; i <= len(input)-1 && unicode.IsSpace(rune(input[i])); i++ {
|
||||||
if i >= len(input) || input[i] == '\n' {
|
if input[i] == '\n' {
|
||||||
return i + 1 - start, ExplicitLineBreak{}
|
return i + 1 - start, ExplicitLineBreak{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
12
org/testdata/misc.html
vendored
12
org/testdata/misc.html
vendored
|
@ -68,9 +68,11 @@
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
<li><a href="#headline-30">index out of range in explicit line break parsing</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="#headline-30">Footnotes</a>
|
<li><a href="#headline-31">Footnotes</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -499,7 +501,13 @@ index out of range in headline priority parsing
|
||||||
<h4 id="headline-29">
|
<h4 id="headline-29">
|
||||||
[#B
|
[#B
|
||||||
</h4>
|
</h4>
|
||||||
<h1 id="headline-30">
|
<h3 id="headline-30">
|
||||||
|
index out of range in explicit line break parsing
|
||||||
|
</h3>
|
||||||
|
<p>
|
||||||
|
0\\
|
||||||
|
</p>
|
||||||
|
<h1 id="headline-31">
|
||||||
Footnotes
|
Footnotes
|
||||||
</h1>
|
</h1>
|
||||||
<div class="footnotes">
|
<div class="footnotes">
|
||||||
|
|
3
org/testdata/misc.org
vendored
3
org/testdata/misc.org
vendored
|
@ -136,6 +136,9 @@ When inserting an image link like [[/home/amos/Pictures/Screenshots/img-2017-09-
|
||||||
** misc fuzz / regression / edge case
|
** misc fuzz / regression / edge case
|
||||||
*** index out of range in headline priority parsing
|
*** index out of range in headline priority parsing
|
||||||
**** [#B
|
**** [#B
|
||||||
|
*** index out of range in explicit line break parsing
|
||||||
|
0\\
|
||||||
|
|
||||||
* Footnotes
|
* Footnotes
|
||||||
|
|
||||||
[fn:1] a footnote /with/ *markup*
|
[fn:1] a footnote /with/ *markup*
|
||||||
|
|
3
org/testdata/misc.pretty_org
vendored
3
org/testdata/misc.pretty_org
vendored
|
@ -136,6 +136,9 @@ When inserting an image link like [[/home/amos/Pictures/Screenshots/img-2017-09-
|
||||||
** misc fuzz / regression / edge case
|
** misc fuzz / regression / edge case
|
||||||
*** index out of range in headline priority parsing
|
*** index out of range in headline priority parsing
|
||||||
**** [#B
|
**** [#B
|
||||||
|
*** index out of range in explicit line break parsing
|
||||||
|
0\\
|
||||||
|
|
||||||
* Footnotes
|
* Footnotes
|
||||||
|
|
||||||
[fn:1] a footnote /with/ *markup*
|
[fn:1] a footnote /with/ *markup*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue