about summary refs log tree commit diff stats
path: root/src/css
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-03-02 13:25:25 +0100
committerbptato <nincsnevem662@gmail.com>2024-03-02 13:26:14 +0100
commitc64617b0bf11fc0d805cb921c8931938a2b18225 (patch)
tree48a1c8021f4f3708fedd66a59f9fb5f0cb899099 /src/css
parent2d32034863eaaf9d8dfe359f11f4f17f097e271f (diff)
downloadchawan-c64617b0bf11fc0d805cb921c8931938a2b18225.tar.gz
cssparser: fix anb parser whitespace handling bugs
* skip whitespace in some places where we didn't but should
* fix crash in get_tok when eof comes after whitespace
Diffstat (limited to 'src/css')
-rw-r--r--src/css/cssparser.nim11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/css/cssparser.nim b/src/css/cssparser.nim
index 57f46015..7152254f 100644
--- a/src/css/cssparser.nim
+++ b/src/css/cssparser.nim
@@ -859,8 +859,8 @@ proc parseAnB*(state: var CSSParseState): Option[CSSAnB] =
     else:
       false
   template get_tok: CSSToken =
-    fail_eof
     skip_whitespace
+    fail_eof
     CSSToken(state.consume())
   template get_tok_nows: CSSToken =
     fail_eof
@@ -902,9 +902,10 @@ proc parseAnB*(state: var CSSParseState): Option[CSSAnB] =
       fail_plus
       return some((2, 0))
     of "n", "N":
+      skip_whitespace
       if is_eof:
         return some((1, 0))
-      let tok2 = get_tok
+      let tok2 = get_tok_nows
       if tok2.tokenType == CSS_DELIM_TOKEN:
         let sign = case tok2.cvalue
         of '+': 1
@@ -918,9 +919,10 @@ proc parseAnB*(state: var CSSParseState): Option[CSSAnB] =
         return some((1, int(tok2.nvalue)))
     of "-n", "-N":
       fail_plus
+      skip_whitespace
       if is_eof:
         return some((-1, 0))
-      let tok2 = get_tok
+      let tok2 = get_tok_nows
       if tok2.tokenType == CSS_DELIM_TOKEN:
         let sign = case tok2.cvalue
         of '+': 1
@@ -965,9 +967,10 @@ proc parseAnB*(state: var CSSParseState): Option[CSSAnB] =
     case tok.unit
     of "n", "N":
       # <n-dimension>
+      skip_whitespace
       if is_eof:
         return some((int(tok.nvalue), 0))
-      let tok2 = get_tok
+      let tok2 = get_tok_nows
       if tok2.tokenType == CSS_DELIM_TOKEN:
         let sign = case tok2.cvalue
         of '+': 1