From 57569bad35dcd01ae6b1e2e01fb2ce4446d1b153 Mon Sep 17 00:00:00 2001 From: totoro Date: Fri, 1 May 2015 23:11:39 +0200 Subject: [PATCH] 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 --- web/js_tools.anubis | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/web/js_tools.anubis b/web/js_tools.anubis index d8ba1cb..06ae9be 100644 --- a/web/js_tools.anubis +++ b/web/js_tools.anubis @@ -20,9 +20,12 @@ define List(Word8) [ ] then reverse(so_far), [h . t] then make_js_string(t, - if h = '\'' then - [h . ['\\' . so_far]] - else + if h = '\'' then [ h, '\\' . so_far] //single quote + else if h = '\r' then ['r', '\\' . so_far] //CR + else if h = '\n' then ['n', '\\' . so_far] //LF + else if h = '\t' then ['t', '\\' . so_far] //tab + else if h = 0x08 then ['b', '\\' . so_far] //Backspace + else [h . so_far] ) }. @@ -44,12 +47,12 @@ public define String String str ) = - "'" + str + "'". + "'" + make_js_string(str) + "'". public define String format_js_function_call ( - String name, - List(String) args + String name, + List(String) args ) = name + "(" + concat(args, ",") + ");". -- libgit2 0.21.4