Subject: | EXEC broken for multiple values in $options |
The AGI expects to see "EXEC command "OPTIONS""
Since most of the EXEC calls people do don't have any spaces, this
hasn't been a problem. But when trying to do this:
$agi->exec("AddSipHeader", "P-Asserted-Identity:
<sip:+17035551212@123.45.67.89>");
Resulted in
EXEC AddSipHeader P-Asserted-Identity:
<sip:+17035551212@123.45.67.89>
When it would have been:
EXEC AddSipHeader "P-Asserted-Identity: <sip:+17035551212@123.45.67.89>"
The following diff fixes warnings about undef variables as well as fixes
this problem.
--- asterisk-perl-0.09/lib/Asterisk.pm Mon Sep 25 08:42:54 2006
+++ modded/lib/Asterisk.pm Mon Jun 25 19:01:09 2007
@@ -4,6 +4,7 @@
package Asterisk;
require 5.004;
+use vars qw($VERSION);
$VERSION = '0.09';
--- asterisk-perl-0.09/lib/Asterisk/AGI.pm Wed Sep 27 19:53:15 2006
+++ modded/lib/Asterisk/AGI.pm Mon Jun 25 19:01:22 2007
@@ -6,9 +6,11 @@
use warnings;
use Asterisk;
-use vars qw(@ISA);
+use vars qw(@ISA $VERSION);
@ISA = ( 'Asterisk' );
+$VERSION = $Asterisk::VERSION;
+
=head1 NAME
Asterisk::AGI - Simple Asterisk Gateway Interface Class
@@ -393,7 +395,7 @@
=item $AGI->exec($app, $options)
-Executes AGI Command "EXEC $app $options"
+Executes AGI Command "EXEC $app "$options""
The most powerful AGI command. Executes the given application passing
the given options.
@@ -407,8 +409,8 @@
sub exec {
my ($self, $app, $options) = @_;
return -1 if (!defined($app));
- $options = '""' if (!defined($options));
- return $self->execute("EXEC $app $options");
+ $options = '' if (!defined($options));
+ return $self->execute("EXEC $app \"$options\"");
}
=item $AGI->get_data($filename, $timeout, $maxdigits)