diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-06-03 06:29:10 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-06-03 06:29:10 -0700 |
commit | 4edb6eac41259a43a547772c4249ba2d6cc68106 (patch) | |
tree | 5ef739853974cf1f148f7733d0d734f0ced27d3e /tests/010 | |
parent | 0f66ac2b5412eb432f165b680fb495f972f33917 (diff) | |
download | txr-4edb6eac41259a43a547772c4249ba2d6cc68106.tar.gz txr-4edb6eac41259a43a547772c4249ba2d6cc68106.tar.bz2 txr-4edb6eac41259a43a547772c4249ba2d6cc68106.zip |
json: improve escaping for script tags.
* lib.c (out_json_str): Strengthen the test for escaping the
forward slash. It has to occur in the sequence </script
rather than just </. Recognize <!-- and --> in the string,
and encode them.
* tests/010/json.tl: Cover this area with some tests.
* txr.1: Documented.
Diffstat (limited to 'tests/010')
-rw-r--r-- | tests/010/json.tl | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/010/json.tl b/tests/010/json.tl index 843b7b58..29ee2833 100644 --- a/tests/010/json.tl +++ b/tests/010/json.tl @@ -94,8 +94,18 @@ (get-json "false") nil (get-json "null") null) -(test - (tojson #(1.0 "abc" t)) "[1,\"abc\",true]") +(mtest + (tojson #(1.0 "abc" t)) "[1,\"abc\",true]" + (tojson "<!--") "\"<\\u0021--\"" + (tojson "a<!--b") "\"a<\\u0021--b\"" + (tojson "<!-") "\"<!-\"" + (tojson "-->") "\"-\\u002D>\"" + (tojson "a-->b") "\"a-\\u002D>b\"" + (tojson "->") "\"->\"" + (tojson "</") "\"</\"" + (tojson "</scrip") "\"</scrip\"" + (tojson "</script") "\"<\\/script\"" + (tojson "a</scriptb") "\"a<\\/scriptb\"") (mtest (get-jsons "") nil |