Author: turnstep
Date: Wed May 14 06:08:45 2008
New Revision: 11266

Modified:
   DBD-Pg/trunk/dbdimp.c
   DBD-Pg/trunk/t/09arrays.t

Log:
When parsing array strings, make sure we continue if inside a quote.
Fixes bug 35862.
New tests for this condition and some similar ones.


Modified: DBD-Pg/trunk/dbdimp.c
==============================================================================
--- DBD-Pg/trunk/dbdimp.c       (original)
+++ DBD-Pg/trunk/dbdimp.c       Wed May 14 06:08:45 2008
@@ -2474,7 +2474,8 @@
                        if ('\\' == *input) { /* Eat backslashes */
                                input++;
                        }
-                       string[section_size++] = *input;
+                       string[section_size++] = *input++;
+                       continue;
                }
                else if ('{' == *input) {
                        AV * const newav = newAV();

Modified: DBD-Pg/trunk/t/09arrays.t
==============================================================================
--- DBD-Pg/trunk/t/09arrays.t   (original)
+++ DBD-Pg/trunk/t/09arrays.t   Wed May 14 06:08:45 2008
@@ -17,7 +17,7 @@
 if (! defined $dbh) {
        plan skip_all => 'Connection to database failed, cannot continue 
testing';
 }
-plan tests => 227;
+plan tests => 245;
 
 isnt( $dbh, undef, 'Connect to database for array testing');
 
@@ -105,6 +105,18 @@
 {abc} quote: {"abc"}
 Simple 1-D text array
 
+['a','b,c']
+{a,"b,c"} quote: {"a","b,c"}
+Text array with commas and quotes
+
+['a','b,}']
+{a,"b,}"} quote: {"a","b,}"}
+Text array with commas, escaped closing brace
+
+['a','b,]']
+{a,"b,]"} quote: {"a","b,]"}
+Text array with commas, escaped closing bracket
+
 [1,2]
 {1,2} quote: {"1","2"}
 Simple 1-D numeric array
@@ -256,10 +268,21 @@
                $qexpected =~ s/\\\\n/\\n/g;
                $qexpected =~ s/\\\\"/\\"/g;
                $qexpected =~ s/\\\\i/\\i/g;
+               if ($msg =~ /closing brace/) {
+                       $qexpected =~ s/]"/}"/;
+               }
                $expected = eval $qexpected;
                is_deeply( $result, $expected, "Correct array inserted: $msg : 
$input");
        }
 
+       if ($msg =~ /STOP/) {
+               warn "Exiting for DEBUGGING. Result is:\n";
+               warn Dumper $result;
+               cleanup_database($dbh,'test');
+               $dbh->disconnect;
+               exit;
+       }
+
 }
 
 $cleararray->execute();

Reply via email to