summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LedgerSMB/DBObject.pm13
-rw-r--r--t/42-dbobject.t12
2 files changed, 16 insertions, 9 deletions
diff --git a/LedgerSMB/DBObject.pm b/LedgerSMB/DBObject.pm
index dade3ab8..6e7abfd4 100644
--- a/LedgerSMB/DBObject.pm
+++ b/LedgerSMB/DBObject.pm
@@ -260,14 +260,10 @@ sub _parse_array {
$next = "";
$separator = "";
if ($value =~ /^\{"/){
- while ($next eq "" or ($next =~ /\\".$/)){
- $value =~ s/^\{("[^"]*".)/\{/;
- $next .= $1;
- $next =~ /(.)$/;
- $separator = $1;
- $next .= "quoted";
- }
- $next =~ s/"(.*)"$separator$/$1/;
+ $value =~ s/^\{"(([^"]|\\")*[^\\])"/\{/;
+ $next = $1;
+ $next =~ /(.)$/;
+ $value =~ s/^{,/{/;
} elsif ($value =~ /^{({+)/){
my $open_braces = $1;
@@ -277,7 +273,6 @@ sub _parse_array {
$value =~ /^{($open_braces[^}]*$close_braces)/;
my $parse_next = $1;
$value =~ s/^{$parse_next/{/;
- $value =~ s/^{,/{/;
@$next = $self->_parse_array($parse_next);
} else {
diff --git a/t/42-dbobject.t b/t/42-dbobject.t
new file mode 100644
index 00000000..6eb42f2f
--- /dev/null
+++ b/t/42-dbobject.t
@@ -0,0 +1,12 @@
+use LedgerSMB::DBObject;
+use Test::More tests => 4;
+
+# Array parsing tests
+my $test = '{test,"test2\"\",",test3,"test4"}';
+my @vals = ('test', 'test2"",', 'test3', 'test4');
+my $passes = 0;
+for (LedgerSMB::DBObject->_parse_array($test)){
+ is($_, shift @vals, "pass $pass, array parse test");
+}
+
+