diff options
-rw-r--r-- | src/encoding/decoderstream.nim (renamed from src/strings/decoderstream.nim) | 8 | ||||
-rw-r--r-- | src/html/htmlparser.nim | 10 | ||||
-rw-r--r-- | src/html/htmltokenizer.nim | 2 | ||||
-rw-r--r-- | src/render/rendertext.nim | 2 |
4 files changed, 11 insertions, 11 deletions
diff --git a/src/strings/decoderstream.nim b/src/encoding/decoderstream.nim index c5f66b3c..15d6311c 100644 --- a/src/strings/decoderstream.nim +++ b/src/encoding/decoderstream.nim @@ -131,7 +131,7 @@ proc decodeUTF8(stream: DecoderStream, iq: var seq[uint8], oq: ptr UncheckedArra bounds.b = 0x8F needed = 3 c = cast[uint32](b) and 0x7 - of 0xF1u8 .. 0xF3u8, 0xF5u8 .. 0xF7u8: + of 0xF1u8 .. 0xF3u8: needed = 3 c = cast[uint32](b) and 0x7 else: @@ -158,6 +158,7 @@ proc decodeUTF8(stream: DecoderStream, iq: var seq[uint8], oq: ptr UncheckedArra inc i stream.c = c stream.u8bounds = bounds + stream.u8seen = seen stream.u8needed = needed proc gb18RangesCodepoint(p: uint32): uint32 = @@ -527,7 +528,7 @@ proc decodeShiftJIS(stream: DecoderStream, iq: var seq[uint8], elif cast[char](b) in Ascii or b == 0x80: stream.append_codepoint b, oq, olen, n elif b in 0xA1u8..0xDFu8: - stream.append_codepoint 0xFF61u16 - 0xA1 + b, oq, olen, n + stream.append_codepoint 0xFF61u16 - 0xA1 + uint16(b), oq, olen, n elif b in {0x81..0x9F} + {0xE0..0xFC}: lead = b else: @@ -826,8 +827,7 @@ proc atEnd*(stream: DecoderStream): bool = return stream.isend proc newDecoderStream*(source: Stream, cs = CHARSET_UTF_8, buflen = 1024, - errormode = DECODER_ERROR_MODE_REPLACEMENT): - DecoderStream = + errormode = DECODER_ERROR_MODE_REPLACEMENT): DecoderStream = result = DecoderStream( source: source, charset: cs, 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 diff --git a/src/render/rendertext.nim b/src/render/rendertext.nim index 68da0557..6c08cefd 100644 --- a/src/render/rendertext.nim +++ b/src/render/rendertext.nim @@ -3,7 +3,7 @@ import unicode import buffer/cell import data/charset -import strings/decoderstream +import encoding/decoderstream import utils/twtstr const tabwidth = 8 |