summaryrefslogtreecommitdiff
path: root/AuthorizeNet
diff options
context:
space:
mode:
authorivan <ivan>2009-11-24 17:52:34 +0000
committerivan <ivan>2009-11-24 17:52:34 +0000
commitef5179790b43cdbbc54601d43dedec645c62d95d (patch)
tree237f978668ce30859872b2679d8f36f5e2245957 /AuthorizeNet
parent92b8ff65410aa005ef662179d123dadf0fd3a155 (diff)
Patch from Josh Rosenbaum to fix encapsulation problems. (closes: CPAN#15210)
Diffstat (limited to 'AuthorizeNet')
-rw-r--r--AuthorizeNet/AIM.pm28
1 files changed, 26 insertions, 2 deletions
diff --git a/AuthorizeNet/AIM.pm b/AuthorizeNet/AIM.pm
index 5324e51..2906079 100644
--- a/AuthorizeNet/AIM.pm
+++ b/AuthorizeNet/AIM.pm
@@ -229,9 +229,33 @@ sub submit {
$post_data{'x_Email_Customer'} = 'FALSE';
}
+ my $data_string = join("", values %post_data);
+
+ my $encap_character;
+ # The first set of characters here are recommended by authorize.net in their
+ # encapsulating character example.
+ # The second set we made up hoping they will work if the first fail.
+ # The third chr(31) is the binary 'unit separator' and is our final last
+ # ditch effort to find something not in the input.
+ foreach my $char( qw( | " ' : ; / \ - * ), '#', qw( ^ + < > [ ] ~), chr(31) ){
+ if( index($data_string, $char) == -1 ){ # found one.
+ $encap_character = $char;
+ last;
+ }
+ }
+
+ if(!$encap_character){
+ $self->is_success(0);
+ $self->error_message(
+ "DEBUG: Input contains all encapsulating characters."
+ . " Please remove | or ^ from your input if possible."
+ );
+ return;
+ }
+
$post_data{'x_ADC_Delim_Data'} = 'TRUE';
$post_data{'x_delim_char'} = ',';
- $post_data{'x_encap_char'} = '"';
+ $post_data{'x_encap_char'} = $encap_character;
$post_data{'x_ADC_URL'} = 'FALSE';
$post_data{'x_Version'} = '3.1';
@@ -247,7 +271,7 @@ sub submit {
#trim 'ip_addr="1.2.3.4"' added by eProcessingNetwork Authorize.Net compat
$page =~ s/,ip_addr="[\d\.]+"$//;
- my $csv = new Text::CSV_XS({ binary=>1, escape_char=>'' });
+ my $csv = new Text::CSV_XS({ binary=>1, escape_char=>'', quote_char => $encap_character });
$csv->parse($page);
my @col = $csv->fields();