aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/config/toml.nim5
-rw-r--r--src/html/dom.nim11
-rw-r--r--src/local/pager.nim3
-rw-r--r--src/utils/twtstr.nim3
4 files changed, 9 insertions, 13 deletions
diff --git a/src/config/toml.nim b/src/config/toml.nim
index c196c6f2..617b11c1 100644
--- a/src/config/toml.nim
+++ b/src/config/toml.nim
@@ -12,7 +12,6 @@ type
tvtInteger = "integer"
tvtFloat = "float"
tvtBoolean = "boolean"
- tvtDateTime = "datetime"
tvtTable = "table"
tvtArray = "array"
@@ -43,8 +42,6 @@ type
b*: bool
of tvtTable:
tab*: TomlTable
- of tvtDateTime:
- dt*: DateTime
of tvtArray:
a*: seq[TomlValue]
ad*: bool
@@ -102,8 +99,6 @@ func `$`*(val: TomlValue): string =
result = $val.b
of tvtTable:
result = $val.t
- of tvtDateTime:
- result = $val.dt
of tvtArray:
#TODO if ad table array probably
result = "["
diff --git a/src/html/dom.nim b/src/html/dom.nim
index 0eedbae6..87a8c940 100644
--- a/src/html/dom.nim
+++ b/src/html/dom.nim
@@ -3233,15 +3233,14 @@ proc loadResource(window: Window; image: HTMLImageElement) =
$response.url)
return
let dims = response.headers.table["Cha-Image-Dimensions"][0]
- let width = parseUInt64(dims.until('x'), allowSign = false)
- let height = parseUInt64(dims.after('x'), allowSign = false)
- if width.isNone or height.isNone or width.get > uint64(int.high) or
- height.get > uint64(int.high):
+ let width = parseIntP(dims.until('x'))
+ let height = parseIntP(dims.after('x'))
+ if width.get(-1) < 0 or height.get(-1) < 0:
window.console.error("wrong Cha-Image-Dimensions in", $response.url)
return
let bmp = NetworkBitmap(
- width: int(width.get),
- height: int(height.get),
+ width: width.get,
+ height: height.get,
cacheId: cacheId,
imageId: window.getImageId(),
contentType: contentType
diff --git a/src/local/pager.nim b/src/local/pager.nim
index e8bb92bf..c3e1a8d1 100644
--- a/src/local/pager.nim
+++ b/src/local/pager.nim
@@ -655,8 +655,7 @@ proc loadCachedImage(pager: Pager; container: Container; image: PosBitmap;
cachedImage.transparent =
response.headers.getOrDefault("Cha-Image-Sixel-Transparent", "0") == "1"
let plens = response.headers.getOrDefault("Cha-Image-Sixel-Prelude-Len")
- if (let plen = parseInt64(plens).get(0); plen <= int64(int.high)):
- cachedImage.preludeLen = int(plen)
+ cachedImage.preludeLen = parseIntP(plens).get(0)
)
)
container.cachedImages.add(cachedImage)
diff --git a/src/utils/twtstr.nim b/src/utils/twtstr.nim
index 342ecede..1f43c443 100644
--- a/src/utils/twtstr.nim
+++ b/src/utils/twtstr.nim
@@ -273,6 +273,9 @@ func parseOctInt64*(s: openArray[char]): Option[int64] =
func parseHexInt64*(s: openArray[char]): Option[int64] =
return parseIntImpl[int64, uint64](s, 16)
+func parseIntP*(s: openArray[char]): Option[int] =
+ return parseIntImpl[int, uint](s, 10)
+
# https://www.w3.org/TR/css-syntax-3/#convert-string-to-number
func parseFloat64*(s: openArray[char]): float64 =
var sign = 1f64