← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~zorba-coders/zorba/bug-1029836 into lp:zorba

 

Ghislain Fourny has proposed merging lp:~zorba-coders/zorba/bug-1029836 into lp:zorba.

Requested reviews:
  Matthias Brantner (matthias-brantner)
Related bugs:
  Bug #1029836 in Zorba: "Segmentation fault or silent accept when performing JSON item selection with less or more than one parameter."
  https://bugs.launchpad.net/zorba/+bug/1029836

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug-1029836/+merge/117250

Corrects bug 1029836.
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1029836/+merge/117250
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-07-24 08:48:48 +0000
+++ include/zorba/pregenerated/diagnostic_list.h	2012-07-30 12:19:20 +0000
@@ -841,6 +841,8 @@
 
 extern ZORBA_DLL_PUBLIC JSONiqErrorCode JNUP0017;
 
+extern ZORBA_DLL_PUBLIC JSONiqErrorCode JNDY0018;
+
 extern ZORBA_DLL_PUBLIC JSONiqErrorCode JNTY0003;
 
 extern ZORBA_DLL_PUBLIC JSONiqErrorCode JSDY0040;

=== modified file 'modules/org/jsoniq/www/pregenerated/errors.xq'
--- modules/org/jsoniq/www/pregenerated/errors.xq	2012-07-11 15:38:39 +0000
+++ modules/org/jsoniq/www/pregenerated/errors.xq	2012-07-30 12:19:20 +0000
@@ -129,6 +129,11 @@
 declare variable $jerr:JNUP0017 as xs:QName := fn:QName($jerr:NS, "jerr:JNUP0017");
 
 (:~
+ :It is a dynamic error if there is not exactly one supplied parameter for an object or array selector.
+:)
+declare variable $jerr:JNDY0018 as xs:QName := fn:QName($jerr:NS, "jerr:JNDY0018");
+
+(:~
  :objects or arrays don't have a string value
 :)
 declare variable $jerr:JNTY0003 as xs:QName := fn:QName($jerr:NS, "jerr:JNTY0003");

=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp	2012-07-24 08:48:48 +0000
+++ src/compiler/translator/translator.cpp	2012-07-30 12:19:20 +0000
@@ -10645,9 +10645,12 @@
   xqtref_t srcType = sourceExpr->get_return_type();
 
   if (!theSctx->is_feature_set(feature::hof) ||
-      (numArgs == 1 &&
-       !TypeOps::is_subtype(tm, *srcType, *theRTM.ANY_FUNCTION_TYPE_STAR)))
+      (!TypeOps::is_subtype(tm, *srcType, *theRTM.ANY_FUNCTION_TYPE_STAR)))
   {
+    if (numArgs != 1)
+    {
+      RAISE_ERROR_NO_PARAMS(jerr::JNDY0018, loc);
+    }
     function* func;
 
     rchandle<flwor_expr> flworExpr = wrap_expr_in_flwor(sourceExpr, false);

=== modified file 'src/diagnostics/diagnostic_en.xml'
--- src/diagnostics/diagnostic_en.xml	2012-07-24 08:48:48 +0000
+++ src/diagnostics/diagnostic_en.xml	2012-07-30 12:19:20 +0000
@@ -2674,6 +2674,12 @@
       <value>Cannot replace with less or more than an item.</value>
     </diagnostic>
     
+    <diagnostic code="JNDY0018" if="defined(ZORBA_WITH_JSON)">
+      <comment>It is a dynamic error if there is not exactly one supplied parameter for an object or array selector.</comment>
+
+      <value>Object or array selection needs exactly one parameter.</value>
+    </diagnostic>
+    
     <!--////////// JSONIQ ///////////////////////////////////////////-->
 
     <diagnostic code="JNTY0003" if="defined(ZORBA_WITH_JSON)">

=== modified file 'src/diagnostics/pregenerated/diagnostic_list.cpp'
--- src/diagnostics/pregenerated/diagnostic_list.cpp	2012-07-24 08:48:48 +0000
+++ src/diagnostics/pregenerated/diagnostic_list.cpp	2012-07-30 12:19:20 +0000
@@ -1237,6 +1237,9 @@
 JSONiqErrorCode JNUP0017( "JNUP0017" );
 
 
+JSONiqErrorCode JNDY0018( "JNDY0018" );
+
+
 JSONiqErrorCode JNTY0003( "JNTY0003" );
 
 

=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
--- src/diagnostics/pregenerated/dict_en.cpp	2012-07-24 08:48:48 +0000
+++ src/diagnostics/pregenerated/dict_en.cpp	2012-07-30 12:19:20 +0000
@@ -101,6 +101,9 @@
   { "JNDY0003", "\"$1\": pair with the same name already exists in object." },
 #endif
 #if defined(ZORBA_WITH_JSON)
+  { "JNDY0018", "Object or array selection needs exactly one parameter." },
+#endif
+#if defined(ZORBA_WITH_JSON)
   { "JNSE0012", "Cannot serialize multiple top-level items as JSON" },
 #endif
 #if defined(ZORBA_WITH_JSON)

=== added file 'test/rbkt/Queries/zorba/jsoniq/jndy0018-1.spec'
--- test/rbkt/Queries/zorba/jsoniq/jndy0018-1.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/jndy0018-1.spec	2012-07-30 12:19:20 +0000
@@ -0,0 +1,1 @@
+Error: http://www.jsoniq.org/errors:JNDY0018

=== added file 'test/rbkt/Queries/zorba/jsoniq/jndy0018-1.xq'
--- test/rbkt/Queries/zorba/jsoniq/jndy0018-1.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/jndy0018-1.xq	2012-07-30 12:19:20 +0000
@@ -0,0 +1,1 @@
+[1, 2]()

=== added file 'test/rbkt/Queries/zorba/jsoniq/jndy0018-2.spec'
--- test/rbkt/Queries/zorba/jsoniq/jndy0018-2.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/jndy0018-2.spec	2012-07-30 12:19:20 +0000
@@ -0,0 +1,1 @@
+Error: http://www.jsoniq.org/errors:JNDY0018

=== added file 'test/rbkt/Queries/zorba/jsoniq/jndy0018-2.xq'
--- test/rbkt/Queries/zorba/jsoniq/jndy0018-2.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/jndy0018-2.xq	2012-07-30 12:19:20 +0000
@@ -0,0 +1,1 @@
+[1, 2](1, 2)

=== added file 'test/rbkt/Queries/zorba/jsoniq/jndy0018-3.spec'
--- test/rbkt/Queries/zorba/jsoniq/jndy0018-3.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/jndy0018-3.spec	2012-07-30 12:19:20 +0000
@@ -0,0 +1,1 @@
+Error: http://www.jsoniq.org/errors:JNDY0018

=== added file 'test/rbkt/Queries/zorba/jsoniq/jndy0018-3.xq'
--- test/rbkt/Queries/zorba/jsoniq/jndy0018-3.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/jndy0018-3.xq	2012-07-30 12:19:20 +0000
@@ -0,0 +1,1 @@
+{ "foo" : "bar" }()

=== added file 'test/rbkt/Queries/zorba/jsoniq/jndy0018-4.spec'
--- test/rbkt/Queries/zorba/jsoniq/jndy0018-4.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/jndy0018-4.spec	2012-07-30 12:19:20 +0000
@@ -0,0 +1,1 @@
+Error: http://www.jsoniq.org/errors:JNDY0018

=== added file 'test/rbkt/Queries/zorba/jsoniq/jndy0018-4.xq'
--- test/rbkt/Queries/zorba/jsoniq/jndy0018-4.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/jndy0018-4.xq	2012-07-30 12:19:20 +0000
@@ -0,0 +1,1 @@
+{ "foo" : "bar" }(1, 2)


Follow ups