aboutsummaryrefslogtreecommitdiffstats
path: root/src/html
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2021-12-19 14:13:40 +0100
committerbptato <nincsnevem662@gmail.com>2021-12-19 14:14:40 +0100
commit61f31f07c04081943382d94554b9eef5aaee1712 (patch)
tree9910c60ff04aef8e998b5e82016b9b56d38a449a /src/html
parent6747131cd3dab85a711f4f96dde92e15e5979c8f (diff)
downloadchawan-61f31f07c04081943382d94554b9eef5aaee1712.tar.gz
Fix html parser bugs
Diffstat (limited to 'src/html')
-rw-r--r--src/html/parser.nim13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/html/parser.nim b/src/html/parser.nim
index 8809e392..8c92b5d6 100644
--- a/src/html/parser.nim
+++ b/src/html/parser.nim
@@ -117,9 +117,9 @@ proc parse_tag(buf: string, at: var int): DOMParsedTag =
tag.open = false
at = skipBlanks(buf, at)
- while at < buf.len and not buf[at].isWhitespace() and not (tag.open and buf[at] == '/') and buf[at] != '>':
+ while at < buf.len and not buf[at].isWhitespace() and not (tag.open and buf[at] == '/') and buf[at] != '>' and buf[at].isAscii():
tagname &= buf[at].tolower()
- at += buf.runeLenAt(at)
+ inc at
tag.tagid = tagType(tagname)
at = skipBlanks(buf, at)
@@ -153,14 +153,15 @@ proc parse_tag(buf: string, at: var int): DOMParsedTag =
inc at
elif at < buf.len:
while at < buf.len and not buf[at].isWhitespace() and buf[at] != '>':
- value &= buf[at]
- at += buf.runeLenAt(at)
+ var r: Rune
+ fastRuneAt(buf, at, r)
+ value &= $r
if attrname.len > 0:
tag.attrs[attrname] = value
while at < buf.len and buf[at] != '>':
- at += buf.runeLenAt(at)
+ inc at
if at < buf.len and buf[at] == '>':
inc at
@@ -463,7 +464,7 @@ proc parseHtml*(inputStream: Stream): Document =
of '>':
till_when = false
else: discard
- at += lineBuf.runeLenAt(at)
+ inc at
if till_when:
continue