OpenPKG CVS Repository http://cvs.openpkg.org/ ____________________________________________________________________________
Server: cvs.openpkg.org Name: Thomas Lotterer Root: /v/openpkg/cvs Email: [EMAIL PROTECTED] Module: openpkg-registry Date: 12-Jul-2006 15:14:41 Branch: HEAD Handle: 2006071214144100 Modified files: openpkg-registry registry-ui.pl Log: get rid of KeyAttr defaults of XML::Simple and stick to obey "id" only; detect and ignore additional nested data structures posted by the client Summary: Revision Changes Path 1.70 +19 -9 openpkg-registry/registry-ui.pl ____________________________________________________________________________ patch -p0 <<'@@ .' Index: openpkg-registry/registry-ui.pl ============================================================================ $ cvs diff -u -r1.69 -r1.70 registry-ui.pl --- openpkg-registry/registry-ui.pl 10 Jul 2006 15:18:31 -0000 1.69 +++ openpkg-registry/registry-ui.pl 12 Jul 2006 13:14:41 -0000 1.70 @@ -1569,7 +1569,7 @@ # FIXME currently we just drop it! $data =~ s|<!DOCTYPE registry[^>]*>||s; - my $ref = eval { local $SIG{__DIE__}; XMLin($data, ForceArray => 1) }; + my $ref = eval { local $SIG{__DIE__}; XMLin($data, ForceArray => 1, KeyAttr => [ "id" ]) }; if ($@) { $msg = $@; $msg =~ s| at \/.*$||; # hide program code file name and line @@ -1642,10 +1642,15 @@ my ($fields, $fieldlist, $fieldbind, $fieldvals, $sth); ($sql, $fields, $fieldlist, $fieldbind, $fieldvals, $sth) = undef; for my $field (sort keys %{$ref->{request}->{$k}}) { - $fieldlist = (defined $fieldlist ? $fieldlist . ", " : "") . $field; - $fieldbind = (defined $fieldbind ? $fieldbind . ", " : "") . "?"; - push @{$fieldvals}, $ref->{request}->{$k}->{$field}; - #FIXME here we could check the validity of all fields with string 'uuid' in their names + if (not ref($ref->{request}->{$k}->{$field})) { + $fieldlist = (defined $fieldlist ? $fieldlist . ", " : "") . $field; + $fieldbind = (defined $fieldbind ? $fieldbind . ", " : "") . "?"; + push @{$fieldvals}, $ref->{request}->{$k}->{$field}; + #FIXME here we could check the validity of all fields with string 'uuid' in their names + } + else { + ; # reserved for nested structures + } } $sql = sprintf("INSERT INTO reg_instance (%s) VALUES (%s);", $fieldlist, $fieldbind); $sth = $dbh->prepare($sql); @@ -1671,12 +1676,17 @@ $fieldlist = 'registry_date = ?'; push @{$fieldvals}, 'now()'; #FIXME this should read DEFAULT or COLUMN_DEF but does not work here for unknown reasons for my $field (sort keys %{$ref->{request}->{$k}}) { - if ($field eq "uuid_registry") { - $rowkey = $ref->{request}->{$k}->{$field} + if (not ref($ref->{request}->{$k}->{$field})) { + if ($field eq "uuid_registry") { + $rowkey = $ref->{request}->{$k}->{$field} + } + else { + $fieldlist = (defined $fieldlist ? $fieldlist . ", " : "") . $field . " = ?"; + push @{$fieldvals}, $ref->{request}->{$k}->{$field}; + } } else { - $fieldlist = (defined $fieldlist ? $fieldlist . ", " : "") . $field . " = ?"; - push @{$fieldvals}, $ref->{request}->{$k}->{$field}; + ; # reserved for nested structures } } $sql = sprintf("UPDATE reg_instance SET %s WHERE ( uuid_registry = ? );", $fieldlist); @@ . ______________________________________________________________________ The OpenPKG Project www.openpkg.org CVS Repository Commit List openpkg-cvs@openpkg.org