Commit 3d60ee18 authored by Frank Bergmann's avatar Frank Bergmann

- Sencha TT:

  Fixed issue with JSON string containing \n
parent 5e4e144a
......@@ -1454,7 +1454,7 @@ ad_proc -private im_rest_post_object_type {
set data_list [list]
foreach key [array names hash_array] {
set value $hash_array($key)
lappend data_list "\"$key\": \"[ns_quotehtml $value]\""
lappend data_list "\"$key\": \"[ns_quotejson $value]\""
}
set data "\[{[join $data_list ", "]}\]"
......@@ -1547,7 +1547,7 @@ ad_proc -private im_rest_post_object {
set data_list [list]
foreach key [array names hash_array] {
set value $hash_array($key)
lappend data_list "\"$key\": \"[ns_quotehtml $value]\""
lappend data_list "\"$key\": \"[im_quotejson $value]\""
}
set data "\[{[join $data_list ", "]}\]"
......
......@@ -870,3 +870,21 @@ ad_proc -public im_rest_parse_xml_json_content {
return [array get hash_array]
}
ad_proc -public im_quotejson { str } {
Quote a JSON string. In particular this means escaping
single and double quotes, as well as new lines, tabs etc.
@author Frank Bergmann
} {
regsub -all {\\} $str {\\\\} str
regsub -all {'} $str {\'} str
regsub -all {"} $str {\"} str
regsub -all {\n} $str {\\n} str
regsub -all {\t} $str {\\t} str
return $str
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment