Paul J. Lucas has proposed merging lp:~paul-lucas/zorba/bug-998757 into 
lp:zorba.

Requested reviews:
  Paul J. Lucas (paul-lucas)
  William Candillon (wcandillon)
Related bugs:
  Bug #998757 in Zorba: "Object form of JsonML causes crash"
  https://bugs.launchpad.net/zorba/+bug/998757

For more details, see:
https://code.launchpad.net/~paul-lucas/zorba/bug-998757/+merge/105584

Added check to see that JsonML (array form) really starts with '['.
-- 
https://code.launchpad.net/~paul-lucas/zorba/bug-998757/+merge/105584
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'include/zorba/pregenerated/diagnostic_list.h'
--- include/zorba/pregenerated/diagnostic_list.h	2012-05-03 12:31:51 +0000
+++ include/zorba/pregenerated/diagnostic_list.h	2012-05-13 15:52:20 +0000
@@ -782,6 +782,8 @@
 
 extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJPE0009_ILLEGAL_EMPTY_STRING;
 
+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJPE0010_JSONML_ARRAY_REQUIRES_BRACKET;
+
 extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJSE0001_NOT_DOCUMENT_OR_ELEMENT_NODE;
 
 extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJSE0002_ELEMENT_MISSING_ATTRIBUTE;

=== modified file 'modules/com/zorba-xquery/www/modules/pregenerated/errors.xq'
--- modules/com/zorba-xquery/www/modules/pregenerated/errors.xq	2012-05-03 12:31:51 +0000
+++ modules/com/zorba-xquery/www/modules/pregenerated/errors.xq	2012-05-13 15:52:20 +0000
@@ -849,6 +849,10 @@
 
 (:~
 :)
+declare variable $zerr:ZJPE0010 as xs:QName := fn:QName($zerr:NS, "zerr:ZJPE0010");
+
+(:~
+:)
 declare variable $zerr:ZJSE0001 as xs:QName := fn:QName($zerr:NS, "zerr:ZJSE0001");
 
 (:~

=== modified file 'src/diagnostics/diagnostic_en.xml'
--- src/diagnostics/diagnostic_en.xml	2012-05-10 03:35:33 +0000
+++ src/diagnostics/diagnostic_en.xml	2012-05-13 15:52:20 +0000
@@ -2438,6 +2438,9 @@
     <diagnostic code="ZJPE0009" name="ILLEGAL_EMPTY_STRING">
       <value>illegal empty string</value>
     </diagnostic>
+    <diagnostic code="ZJPE0010" name="JSONML_ARRAY_REQUIRES_BRACKET">
+      <value>JsonML (array form) must start with '['</value>
+    </diagnostic>
 
    <!--////////// JSON Serialization Errors ////////////////////////////////-->
 

=== modified file 'src/diagnostics/pregenerated/diagnostic_list.cpp'
--- src/diagnostics/pregenerated/diagnostic_list.cpp	2012-05-03 12:31:51 +0000
+++ src/diagnostics/pregenerated/diagnostic_list.cpp	2012-05-13 15:52:20 +0000
@@ -1151,6 +1151,9 @@
 ZorbaErrorCode ZJPE0009_ILLEGAL_EMPTY_STRING( "ZJPE0009" );
 
 
+ZorbaErrorCode ZJPE0010_JSONML_ARRAY_REQUIRES_BRACKET( "ZJPE0010" );
+
+
 ZorbaErrorCode ZJSE0001_NOT_DOCUMENT_OR_ELEMENT_NODE( "ZJSE0001" );
 
 

=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
--- src/diagnostics/pregenerated/dict_en.cpp	2012-05-10 03:35:33 +0000
+++ src/diagnostics/pregenerated/dict_en.cpp	2012-05-13 15:52:20 +0000
@@ -347,6 +347,7 @@
   { "ZJPE0007", "unterminated JSON string" },
   { "ZJPE0008", "\"$1\": illegal QName" },
   { "ZJPE0009", "illegal empty string" },
+  { "ZJPE0010", "JsonML (array form) must start with '['" },
   { "ZJSE0001", "JSON serialization requires document or element node" },
   { "ZJSE0002", "\"$1\" element missing required \"$2\" attribute" },
   { "ZJSE0003", "\"$1\": illegal value for attribute \"$2\"" },

=== modified file 'src/runtime/json/jsonml_array.cpp'
--- src/runtime/json/jsonml_array.cpp	2012-02-08 15:45:53 +0000
+++ src/runtime/json/jsonml_array.cpp	2012-05-13 15:52:20 +0000
@@ -94,6 +94,10 @@
         break;
 
       case '{':
+        if ( state_stack.empty() )
+          throw XQUERY_EXCEPTION(
+            zerr::ZJPE0010_JSONML_ARRAY_REQUIRES_BRACKET
+          );
         PUSH_STATE( in_object );
         expect_what = expect::attribute_name;
         break;

=== added file 'test/rbkt/Queries/zorba/json/json-jsonml_array-parse-07.spec'
--- test/rbkt/Queries/zorba/json/json-jsonml_array-parse-07.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-parse-07.spec	2012-05-13 15:52:20 +0000
@@ -0,0 +1,1 @@
+Error: http://www.zorba-xquery.com/errors:ZJPE0010

=== added file 'test/rbkt/Queries/zorba/json/json-jsonml_array-parse-07.xq'
--- test/rbkt/Queries/zorba/json/json-jsonml_array-parse-07.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-parse-07.xq	2012-05-13 15:52:20 +0000
@@ -0,0 +1,14 @@
+import module namespace json =
+  "http://www.zorba-xquery.com/modules/converters/json";;
+
+let $opt :=
+  <options xmlns="http://www.zorba-xquery.com/modules/converters/json-options";>
+    <json-format value="JsonML-array"/>
+  </options>
+let $json :=
+  '{
+    "args": [ "<div><span>foo:</span> parse</div>" ]
+   }'
+return json:parse( $json, $opt )
+
+(: vim:set et sw=2 ts=2: :)

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to