balakrishna_bk has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I have special character '<' in my password and I get error when i try to login. I tried the following options to encode my password, but still fails

1. add '\' in front of '<' in password 2. passing username and password in url https://username:'pass<1234'@system.test.com' 3. used uri_escape from URI::Escape uri_escape($pwd) 4. encoded using base64 $r->header( "Content-Type" => "application/soap+xml;charset=UTF-8", "S +OAPAction" => "", "Authorization" => "Basic U1BDX1NJVEUyNFg3OjNmUlRMb +2NjQmZmWHk=" ); sub do_webservice { my ( $weburl, $usr, $password, $webxml ) = @_; print FD "\nXML: \n$webxml\n"; print FD "\nURL: \n$weburl\n"; my $ua = LWP::UserAgent->new(); $ua->ssl_opts( verify_hostnames => 0 ); my $r = HTTP::Request->new( "POST", $weburl ) or warn "POST FAIL +ED:$!\n";; $r->header( "Content-Type" => "application/soap+xml;charset=UTF- +8", "SOAPAction" => "" ); $r->authorization_basic( $usr, $password ); $r->content($webxml); my $response = $ua->request($r); print FD "START Dumper of $response\n"; print FD Dumper $response; print FD "END Dumper of $response\n"; print FD "DEBUG: Response is $response \n"; return $response; }

Any help is appreciated. Regards, Bala

Replies are listed 'Best First'.
Re: Special character in authorization_basic
by Yary (Pilgrim) on Feb 10, 2016 at 12:59 UTC
    Have you a sample of code that you have verified works with a "plain" password, one that doesn't contain any angle brackets? It would be good to have for comparison.

      Hi Yes, i tried with plain password and it works, thats when i realised that the problem was with special character in my password. Error: mismatched tag at line 1, column 1101, byte 1101 at /usr/lib64/perl5/XML/Parser.pm line 187

        Error: mismatched tag at line 1, column 1101, byte 1101 at /usr/lib64/perl5/XML/Parser.pm line 187

        Wait, are you putting $password in the body of the XML as well as in the auth header? Probably best to output the XML so you can see where the malformation occurs (ie. what's at byte 1101).