X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=cgi%2Fsoap.cgi;h=8c1ec3c5c3466d45d6168f22ec299311fc2326da;hb=1fbaca61f2f551b5b2645ce2233a1d964bc93b30;hp=6599109cf9ed2a4beeb4daabb81892cdbbed49ab;hpb=0bcab28df52f69d78d262c1284bfe0c0a29b683e;p=debbugs.git diff --git a/cgi/soap.cgi b/cgi/soap.cgi index 6599109..8c1ec3c 100755 --- a/cgi/soap.cgi +++ b/cgi/soap.cgi @@ -1,13 +1,70 @@ -#!/usr/bin/perl -wT +#!/usr/bin/perl -T -package debbugs; +use warnings; +use strict; -use SOAP::Transport::HTTP; +# if we're running out of git, we want to use the git base directory as the +# first INC directory. If you're not running out of git, don't do that. +use File::Basename qw(dirname); +use Cwd qw(abs_path); +our $debbugs_dir; +BEGIN { + $debbugs_dir = + abs_path(dirname(abs_path(__FILE__)) . '/../'); + # clear the taint; we'll assume that the absolute path to __FILE__ is the + # right path if there's a .git directory there + ($debbugs_dir) = $debbugs_dir =~ /([[:print:]]+)/; + if (defined $debbugs_dir and + -d $debbugs_dir . '/.git/') { + } else { + undef $debbugs_dir; + } + # if the first directory in @INC is not an absolute directory, assume that + # someone has overridden us via -I. + if ($INC[0] !~ /^\//) { + } +} +use if defined $debbugs_dir, lib => $debbugs_dir; -use Debbugs::SOAP::Usertag; -use Debbugs::SOAP::Status; +#use SOAP::Transport::HTTP; -SOAP::Transport::HTTP::CGI - -> dispatch_to('Debbugs::SOAP::Usertag', 'Debbugs::SOAP::Status') - -> handle; +use Debbugs::SOAP::Server; +# Work around stupid soap bug on line 411 +if (not exists $ENV{EXPECT}) { + $ENV{EXPECT} = ''; +} + +my $soap = Debbugs::SOAP::Server +#my $soap = SOAP::Transport::HTTP::CGI + -> dispatch_to('Debbugs::SOAP'); +#$soap->serializer()->soapversion(1.2); +# soapy is stupid, and is using the 1999 schema; override it. +*SOAP::XMLSchema1999::Serializer::as_base64Binary = \&SOAP::XMLSchema2001::Serializer::as_base64Binary; +*SOAP::Serializer::as_anyURI = \&SOAP::XMLSchema2001::Serializer::as_string; +# do this twice to avoid the warning if the serializer doesn't get +# used +*SOAP::XMLSchema1999::Serializer::as_base64Binary = \&SOAP::XMLSchema2001::Serializer::as_base64Binary; +*SOAP::Serializer::as_anyURI = \&SOAP::XMLSchema2001::Serializer::as_string; +# to work around the serializer improperly using date/time stuff +# (Nothing in Debbugs should be looked at as if it were date/time) we +# kill off all of the date/time related bits in the serializer. +my $typelookup = $soap->serializer()->{_typelookup}; +for my $key (keys %{$typelookup}) { + if (defined $key and + $key =~ /Month|Day|Year|date|time|duration/i + ) { + # set the sub to always return 0 + $typelookup->{$key}[1] = sub { 0 }; + } +} + +our $warnings = ''; +eval { + # Ignore stupid warning because elements (hashes) can't start with + # numbers + local $SIG{__WARN__} = sub {$warnings .= $_[0] unless $_[0] =~ /Cannot encode unnamed element/}; + $soap->handle; +}; +die $@ if $@; +warn $warnings if length $warnings;