[mapserver-dev] mapscript swig modperl SOLVED
Andy Colson
andy at squeakycode.net
Tue Aug 18 10:54:38 EDT 2009
Andy Colson wrote:
> Hi Devs,
>
> I'm having a problem in perl mapscript.
>
> As a normal perlscript (run from command line, or cgi or fastcgi) it
> works ok, but when run under modperl I have problems.
>
> This line works:
> my $map = new mapscript::mapObj("/pub/maps/test.map");
>
>
> This does not:
> my $s = "/pub/maps/test.map";
> my $map = new mapscript::mapObj($s);
>
> I get error:
> TypeError in method 'new_mapObj', argument 1 of type 'char *'
>
> Here is my test script:
>
> use strict;
> use aweb;
> use mapscript;
>
> my $web = aweb->new(shift);
> $web->content_type("text/html");
>
>
> #my $s = "/pub/maps/test.map";
> #my $map = new mapscript::mapObj($s);
> my $map = new mapscript::mapObj("/pub/maps/test.map");
> if (! $map)
> {
> print "failed to load<br>";
> } else {
> print "loaded<br>";
> }
>
>
>
>
> Any help would be appreciated.
>
> -Andy
Ok, my bad.
The example above was a "simplified version", which, unfortunately,
works fine. The code that does not work is this:
my $xmap = $web->param('map');
my $s = "/pub/maps/$xmap.map";
my $map = new mapscript::mapObj($s);
And its because I have taint mode enabled. So $xmap is tainted, which
taints $s, and I guess that's not passed as a char* to swig.
To fix it:
my $xmap = $web->param('map');
$xmap =~ /(\w+)/;
$xmap = $1; # untaint $xmap
my $s = "/pub/maps/$xmap.map";
my $map = new mapscript::mapObj($s);
And it seems to work fine.
sorry for the noise. (a good nights sleep is still the best debugger)
-Andy
More information about the mapserver-dev
mailing list