Skip to content
Browse files

Only apply GDBM filters if they are not already installed

In certain circumstances, using the same GDBM-based file in multiple catalogs with
GDBM_ENABLE_UTF8=1 set was causing the GDBM filters to be installed multiple times on the same
handle, which was resulting in encoding/decoding errors.

Vend::Table::GDBM will now only install the filters if they do not exist on this handle, which
should preserve existing behavior plus account for these corner-cases.
  • Loading branch information...
1 parent 8e1f300 commit 0c31ea3287df97c8fedbf23ad71244e4ebe019c7 @machack666 machack666 committed Aug 30, 2012
Showing with 4 additions and 4 deletions.
  1. +4 −4 lib/Vend/Table/GDBM.pm
View
8 lib/Vend/Table/GDBM.pm
@@ -150,10 +150,10 @@ sub apply_utf8_filters {
my $out_filter = sub { $_ = encode('utf-8', $_) };
my $in_filter = sub { $_ = decode('utf-8', $_) };
- $handle->filter_store_key($out_filter);
- $handle->filter_store_value($out_filter);
- $handle->filter_fetch_key($in_filter);
- $handle->filter_fetch_value($in_filter);
+ $handle->filter_store_key($out_filter) unless $handle->filter_store_key();
+ $handle->filter_store_value($out_filter) unless $handle->filter_store_value();
+ $handle->filter_fetch_key($in_filter) unless $handle->filter_fetch_key();
+ $handle->filter_fetch_value($in_filter) unless $handle->filter_fetch_value();
return $handle;
}

0 comments on commit 0c31ea3

Please sign in to comment.
Something went wrong with that request. Please try again.