Merge lp:~zorba-coders/zorba/bug_867198 into lp:~zorba-coders/zorba/data-converters-module

Proposed by Sorin Marian Nasoi
Status: Merged
Approved by: Carlos Manuel Lopez
Approved revision: 76
Merged at revision: 76
Proposed branch: lp:~zorba-coders/zorba/bug_867198
Merge into: lp:~zorba-coders/zorba/data-converters-module
Diff against target: 78 lines (+25/-9)
5 files modified
src/com/zorba-xquery/www/modules/converters/json.xq.src/jansson_wrapper.cpp (+12/-9)
test_json/ExpQueryResults/converters/jansson/parse_json_12.xml.res (+1/-0)
test_json/ExpQueryResults/converters/jansson/parse_json_ml_06.xml.res (+1/-0)
test_json/Queries/converters/jansson/parse_json_12.xq (+4/-0)
test_json/Queries/converters/jansson/parse_json_ml_06.xq (+7/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/bug_867198
Reviewer Review Type Date Requested Status
Carlos Manuel Lopez (community) Approve
Sorin Marian Nasoi Approve
Review via email: mp+84617@code.launchpad.net

Commit message

Fixed bug #867198. Also added 2 tests.

Description of the change

Fixed bug #867198. Also added 2 tests.

To post a comment you must log in.
Revision history for this message
Sorin Marian Nasoi (sorin.marian.nasoi) wrote :

Approved.

review: Approve
Revision history for this message
Carlos Manuel Lopez (charlie-lobo) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug_867198-2011-12-07T16-45-50.256Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/com/zorba-xquery/www/modules/converters/json.xq.src/jansson_wrapper.cpp'
2--- src/com/zorba-xquery/www/modules/converters/json.xq.src/jansson_wrapper.cpp 2011-10-06 07:40:17 +0000
3+++ src/com/zorba-xquery/www/modules/converters/json.xq.src/jansson_wrapper.cpp 2011-12-06 14:25:25 +0000
4@@ -68,14 +68,16 @@
5 void replace_special_chars(
6 std::string &aValue)
7 {
8- replace_all(aValue, "\"", "\\\""); //quotation mark
9- replace_all(aValue, "\\", "\\\\"); //reverse solidus
10- replace_all(aValue, "/", "\\/"); //solidus
11- replace_all(aValue, "\b", "\\b" ); //backspace
12- replace_all(aValue, "\f", "\\f" ); //formfeed
13- replace_all(aValue, "\n", "\\n" ); //new line
14- replace_all(aValue, "\r", "\\r" ); //carriage return
15- replace_all(aValue, "\t", "\\t" ); //horizontal tab
16+ replace_all(aValue, "\"", "\\\"" ); //quotation mark
17+ replace_all(aValue, "\\", "\\\\" ); //reverse solidus
18+ replace_all(aValue, "/" , "\\/" ); //solidus
19+ replace_all(aValue, "\b", "\\b" ); //backspace
20+ replace_all(aValue, "\f", "\\f" ); //formfeed
21+ replace_all(aValue, "\n", "\\n" ); //new line
22+ replace_all(aValue, "\r", "\\r" ); //carriage return
23+ replace_all(aValue, "\t", "\\t" ); //horizontal tab
24+ replace_all(aValue, "<" , "&lt;" ); // <
25+ replace_all(aValue, ">" , "&gt;" ); // >
26 }
27
28 static void parse_Json_value(
29@@ -557,7 +559,7 @@
30 }
31 default:
32 {
33- zorba::String lType, lValue;
34+ std::string lType, lValue;
35 if(json_is_string(aValue))
36 {
37 lType = "string";
38@@ -591,6 +593,7 @@
39 else if(lParent.compare("object") == 0)
40 {
41 aSs << " " << lName << "=";
42+ replace_special_chars(lValue);
43 if(lType.compare("string") == 0)
44 aSs << "\"" << lValue << "\"";
45 else
46
47=== added file 'test_json/ExpQueryResults/converters/jansson/parse_json_12.xml.res'
48--- test_json/ExpQueryResults/converters/jansson/parse_json_12.xml.res 1970-01-01 00:00:00 +0000
49+++ test_json/ExpQueryResults/converters/jansson/parse_json_12.xml.res 2011-12-06 14:25:25 +0000
50@@ -0,0 +1,1 @@
51+{"html": "&lt;b&gt;bold&lt;\/b&gt;"}
52
53=== added file 'test_json/ExpQueryResults/converters/jansson/parse_json_ml_06.xml.res'
54--- test_json/ExpQueryResults/converters/jansson/parse_json_ml_06.xml.res 1970-01-01 00:00:00 +0000
55+++ test_json/ExpQueryResults/converters/jansson/parse_json_ml_06.xml.res 2011-12-06 14:25:25 +0000
56@@ -0,0 +1,1 @@
57+<html><b>bold</b></html>
58
59=== added file 'test_json/Queries/converters/jansson/parse_json_12.xq'
60--- test_json/Queries/converters/jansson/parse_json_12.xq 1970-01-01 00:00:00 +0000
61+++ test_json/Queries/converters/jansson/parse_json_12.xq 2011-12-06 14:25:25 +0000
62@@ -0,0 +1,4 @@
63+import module namespace json="http://www.zorba-xquery.com/modules/converters/json";
64+declare variable $json-value := '{"html":"<b>bold</b>"}';
65+
66+json:serialize(json:parse($json-value))
67
68=== added file 'test_json/Queries/converters/jansson/parse_json_ml_06.xq'
69--- test_json/Queries/converters/jansson/parse_json_ml_06.xq 1970-01-01 00:00:00 +0000
70+++ test_json/Queries/converters/jansson/parse_json_ml_06.xq 2011-12-06 14:25:25 +0000
71@@ -0,0 +1,7 @@
72+import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";
73+import schema namespace html-options="http://www.zorba-xquery.com/modules/converters/json-options";
74+
75+json:parse('["html" ,"<b>bold</b>"]',<options xmlns="http://www.zorba-xquery.com/modules/converters/json-options"
76+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
77+ <json-param name="mapping" value="json-ml" type="array"/>
78+ </options>)

Subscribers

People subscribed via source and target branches

to all changes: