about summary refs log tree commit diff stats
path: root/src/html
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-12-10 19:48:11 +0100
committerbptato <nincsnevem662@gmail.com>2022-12-10 19:48:11 +0100
commit5c267ce6c9c1add997767f5eaad248cdd829c6fc (patch)
treee3b8a1cdd7f7f67f2d810ce1747fa197c1387ff1 /src/html
parent78cc5143a3a98f2803258d42818cf17727d70fe7 (diff)
downloadchawan-5c267ce6c9c1add997767f5eaad248cdd829c6fc.tar.gz
Fix decoder bugs, move decoder to encoding/
Diffstat (limited to 'src/html')
-rw-r--r--src/html/htmlparser.nim10
-rw-r--r--src/html/htmltokenizer.nim2
2 files changed, 6 insertions, 6 deletions
diff --git a/src/html/htmlparser.nim b/src/html/htmlparser.nim
index ce8ce2bb..ebdc6645 100644
--- a/src/html/htmlparser.nim
+++ b/src/html/htmlparser.nim
@@ -12,8 +12,8 @@ import data/charset
 import html/dom
 import html/tags
 import html/htmltokenizer
+import encoding/decoderstream
 import js/javascript
-import strings/decoderstream
 import utils/twtstr
 
 type
@@ -574,23 +574,23 @@ func extractEncFromMeta(s: string): Charset =
       of 5: check 'e'
       of 6: check 't'
       of 7:
-        inc i
+        inc j
         break
       else: discard
       inc i
     if j < 7: return CHARSET_UNKNOWN
-    j = 0
     while i < s.len and s[i] in AsciiWhitespace: inc i
     if i >= s.len or s[i] != '=': continue
     while i < s.len and s[i] in AsciiWhitespace: inc i
     break
+  inc i
   if i >= s.len: return CHARSET_UNKNOWN
   if s[i] in {'"', '\''}:
-    let s2 = s.substr(i).until(s[i])
+    let s2 = s.substr(i + 1).until(s[i])
     if s2.len == 0 or s2[^1] != s[i]:
       return CHARSET_UNKNOWN
     return getCharset(s2)
-  return getCharset(s.substr(i - 1).until({';', ' '}))
+  return getCharset(s.substr(i).until({';', ' '}))
 
 proc changeEncoding(parser: var HTML5Parser, cs: Charset) =
   if parser.charset in {CHARSET_UTF_16_LE, CHARSET_UTF_16_BE}:
diff --git a/src/html/htmltokenizer.nim b/src/html/htmltokenizer.nim
index 08779c24..a8961e2f 100644
--- a/src/html/htmltokenizer.nim
+++ b/src/html/htmltokenizer.nim
@@ -7,7 +7,7 @@ import unicode
 
 import html/entity
 import html/tags
-import strings/decoderstream
+import encoding/decoderstream
 import utils/radixtree
 import utils/twtstr