Handle malformed :PROPERTY: drawers
Until now we'd get index out of range errors trying to index into the match if :PROPERTIES: was followed by a non-property. Thanks fuzz
This commit is contained in:
parent
76b157b8ce
commit
adeeb9235d
5 changed files with 28 additions and 0 deletions
|
@ -67,6 +67,9 @@ func (d *Document) parsePropertyDrawer(i int, parentStop stopFn) (int, Node) {
|
||||||
}
|
}
|
||||||
for ; !stop(d, i); i++ {
|
for ; !stop(d, i); i++ {
|
||||||
m := propertyRegexp.FindStringSubmatch(d.tokens[i].matches[0])
|
m := propertyRegexp.FindStringSubmatch(d.tokens[i].matches[0])
|
||||||
|
if m == nil {
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
k, v := strings.ToUpper(m[2]), strings.TrimSpace(m[4])
|
k, v := strings.ToUpper(m[2]), strings.TrimSpace(m[4])
|
||||||
drawer.Properties = append(drawer.Properties, []string{k, v})
|
drawer.Properties = append(drawer.Properties, []string{k, v})
|
||||||
}
|
}
|
||||||
|
|
12
org/testdata/headlines.html
vendored
12
org/testdata/headlines.html
vendored
|
@ -12,6 +12,8 @@
|
||||||
</li>
|
</li>
|
||||||
<li><a href="#headline-6">excluded headline</a>
|
<li><a href="#headline-6">excluded headline</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li><a href="#headline-7">malformed property drawer</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
<h1 id="headline-1">
|
<h1 id="headline-1">
|
||||||
|
@ -76,3 +78,13 @@ it's possible to use <code class="verbatim">#+SETUPFILE</code> - in this cas
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<h1 id="headline-7">
|
||||||
|
malformed property drawer
|
||||||
|
</h1>
|
||||||
|
<p>
|
||||||
|
:PROPERTIES:
|
||||||
|
not a property
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
:END:
|
||||||
|
</p>
|
||||||
|
|
4
org/testdata/headlines.org
vendored
4
org/testdata/headlines.org
vendored
|
@ -27,3 +27,7 @@ it's possible to use =#+SETUPFILE= - in this case the setup file contains the fo
|
||||||
this headline and it's content are not exported as it is marked with an =EXCLUDE_TAGS= tag.
|
this headline and it's content are not exported as it is marked with an =EXCLUDE_TAGS= tag.
|
||||||
By default =EXCLUDE_TAGS= is just =:noexport:=.
|
By default =EXCLUDE_TAGS= is just =:noexport:=.
|
||||||
|
|
||||||
|
* malformed property drawer
|
||||||
|
:PROPERTIES:
|
||||||
|
not a property
|
||||||
|
:END:
|
||||||
|
|
4
org/testdata/headlines.pretty_org
vendored
4
org/testdata/headlines.pretty_org
vendored
|
@ -27,3 +27,7 @@ it's possible to use =#+SETUPFILE= - in this case the setup file contains the fo
|
||||||
this headline and it's content are not exported as it is marked with an =EXCLUDE_TAGS= tag.
|
this headline and it's content are not exported as it is marked with an =EXCLUDE_TAGS= tag.
|
||||||
By default =EXCLUDE_TAGS= is just =:noexport:=.
|
By default =EXCLUDE_TAGS= is just =:noexport:=.
|
||||||
|
|
||||||
|
* malformed property drawer
|
||||||
|
:PROPERTIES:
|
||||||
|
not a property
|
||||||
|
:END:
|
||||||
|
|
5
org/testdata/misc.html
vendored
5
org/testdata/misc.html
vendored
|
@ -145,6 +145,11 @@ it's possible to use =#+SETUPFILE= - in this case the setup file contains th
|
||||||
* excluded headline :custom_noexport:
|
* excluded headline :custom_noexport:
|
||||||
this headline and it's content are not exported as it is marked with an =EXCLUDE_TAGS= tag.
|
this headline and it's content are not exported as it is marked with an =EXCLUDE_TAGS= tag.
|
||||||
By default =EXCLUDE_TAGS= is just =:noexport:=.
|
By default =EXCLUDE_TAGS= is just =:noexport:=.
|
||||||
|
|
||||||
|
* malformed property drawer
|
||||||
|
:PROPERTIES:
|
||||||
|
not a property
|
||||||
|
:END:
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue