[interchange-cvs] interchange - jon modified lib/Vend/Data.pm
interchange-core@interchange.redhat.com
interchange-core@interchange.redhat.com
Thu Oct 25 19:29:01 2001
User: jon
Date: 2001-10-25 23:26:06 GMT
Modified: lib/Vend Tag: STABLE_4_8-branch Data.pm
Log:
Prevent corruption of tab-delimited DB exports by filtering tabs to spaces.
Unfortunately any delimiter presents these kinds of problems, but few have
fairly safe default replacements like tab->space.
Also make a tiny optimization around $nuke checking.
Revision Changes Path
No revision
No revision
2.0.2.3 +7 -2 interchange/lib/Vend/Data.pm
rev 2.0.2.3, prev_rev 2.0.2.2
Index: Data.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Data.pm,v
retrieving revision 2.0.2.2
retrieving revision 2.0.2.3
diff -u -u -r2.0.2.2 -r2.0.2.3
--- Data.pm 2001/10/18 11:31:40 2.0.2.2
+++ Data.pm 2001/10/25 23:26:06 2.0.2.3
@@ -1,6 +1,6 @@
# Vend::Data - Interchange databases
#
-# $Id: Data.pm,v 2.0.2.2 2001/10/18 11:31:40 racke Exp $
+# $Id: Data.pm,v 2.0.2.3 2001/10/25 23:26:06 jon Exp $
#
# Copyright (C) 1996-2001 Red Hat, Inc. <interchange@redhat.com>
#
@@ -1197,9 +1197,11 @@
elsif($record_delim eq "\n") {
print EXPORT join $delim, @cols;
print EXPORT $record_delim;
+ my $detab = ($delim eq "\t") ? 1 : 0;
if(defined $nuke) {
while( (undef, @data) = $db->each_record() ) {
- splice(@data, $nuke, 1) if defined $nuke;
+ splice(@data, $nuke, 1);
+ if ($detab) { s/\t/ /g for @data; }
$tempdata = join $delim, @data;
$tempdata =~ s/\r?\n/\r/g;
print EXPORT $tempdata, $record_delim;
@@ -1207,6 +1209,7 @@
}
else {
while( (undef, @data) = $db->each_record() ) {
+ if ($detab) { s/\t/ /g for @data; }
$tempdata = join $delim, @data;
$tempdata =~ s/\r?\n/\r/g;
print EXPORT $tempdata, $record_delim;
@@ -1216,8 +1219,10 @@
else {
print EXPORT join $delim, @cols;
print EXPORT $record_delim;
+ my $detab = ($delim eq "\t" or $record_delim eq "\t") ? 1 : 0;
while( (undef, @data) = $db->each_record() ) {
splice(@data, $nuke, 1) if defined $nuke;
+ if ($detab) { s/\t/ /g for @data; }
print EXPORT join($delim, @data);
print EXPORT $record_delim;
}