aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2018-04-15 17:54:11 +0300
committerTulir Asokan <tulir@maunium.net>2018-04-15 17:54:11 +0300
commit0d4d597909a47f5e0d0171b1c2f322085eacee57 (patch)
treee3b214a1ef10d0b45c59f7b2b8d3cff407ff79d6 /ui
parent0cdde557a3ed7624de31aa844929037b65e1fe11 (diff)
Fix panic in HTML parser (#20)
Diffstat (limited to 'ui')
-rw-r--r--ui/messages/parser/htmltagarray.go24
1 files changed, 3 insertions, 21 deletions
diff --git a/ui/messages/parser/htmltagarray.go b/ui/messages/parser/htmltagarray.go
index 4cd4245..d66d7d9 100644
--- a/ui/messages/parser/htmltagarray.go
+++ b/ui/messages/parser/htmltagarray.go
@@ -30,26 +30,6 @@ var BlankTag = &TagWithMeta{}
// TagArray is a reversed queue for remembering what HTML tags are open.
type TagArray []*TagWithMeta
-// Pushb converts the given byte array into a string and calls Push().
-func (ta *TagArray) Pushb(tag []byte) {
- ta.Push(string(tag))
-}
-
-// Popb converts the given byte array into a string and calls Pop().
-func (ta *TagArray) Popb(tag []byte) *TagWithMeta {
- return ta.Pop(string(tag))
-}
-
-// Indexb converts the given byte array into a string and calls Index().
-func (ta *TagArray) Indexb(tag []byte) {
- ta.Index(string(tag))
-}
-
-// IndexAfterb converts the given byte array into a string and calls IndexAfter().
-func (ta *TagArray) IndexAfterb(tag []byte, after int) {
- ta.IndexAfter(string(tag), after)
-}
-
// Push adds the given tag to the array.
func (ta *TagArray) Push(tag string) {
ta.PushMeta(&TagWithMeta{Tag: tag})
@@ -64,7 +44,9 @@ func (ta *TagArray) PushMeta(tag *TagWithMeta) {
// Pop removes the given tag from the array.
func (ta *TagArray) Pop(tag string) (removed *TagWithMeta) {
- if (*ta)[0].Tag == tag {
+ if len(*ta) == 0 {
+ return
+ } else if (*ta)[0].Tag == tag {
// This is the default case and is lighter than append(), so we handle it separately.
removed = (*ta)[0]
*ta = (*ta)[1:]