Commit 57569bad35dcd01ae6b1e2e01fb2ce4446d1b153

Authored by totoro
1 parent 24253864

fix make_js_string. Now treat all CR LF TAB BACK native code to escaped sequence

to_js_string call also make_js_string to avoid the user to call it before use to_js_string
Showing 1 changed file with 9 additions and 6 deletions   Show diff stats
web/js_tools.anubis
@@ -20,9 +20,12 @@ define List(Word8) @@ -20,9 +20,12 @@ define List(Word8)
20 [ ] then reverse(so_far), 20 [ ] then reverse(so_far),
21 [h . t] then 21 [h . t] then
22 make_js_string(t, 22 make_js_string(t,
23 - if h = '\'' then  
24 - [h . ['\\' . so_far]]  
25 - else 23 + if h = '\'' then [ h, '\\' . so_far] //single quote
  24 + else if h = '\r' then ['r', '\\' . so_far] //CR
  25 + else if h = '\n' then ['n', '\\' . so_far] //LF
  26 + else if h = '\t' then ['t', '\\' . so_far] //tab
  27 + else if h = 0x08 then ['b', '\\' . so_far] //Backspace
  28 + else
26 [h . so_far] 29 [h . so_far]
27 ) 30 )
28 }. 31 }.
@@ -44,12 +47,12 @@ public define String @@ -44,12 +47,12 @@ public define String
44 String str 47 String str
45 ) 48 )
46 = 49 =
47 - "'" + str + "'". 50 + "'" + make_js_string(str) + "'".
48 51
49 public define String 52 public define String
50 format_js_function_call 53 format_js_function_call
51 ( 54 (
52 - String name,  
53 - List(String) args 55 + String name,
  56 + List(String) args
54 ) = 57 ) =
55 name + "(" + concat(args, ",") + ");". 58 name + "(" + concat(args, ",") + ");".