Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Escape special characters in password

Status
Not open for further replies.

thendal

Programmer
Aug 23, 2000
284
Hi All!

I am using Net::IMAP::Simple module to authenticate a set of users against our mail server.

Here is a sample code.

Code:
use CGI;
use Net::IMAP::Simple;
$server = new Net::IMAP::Simple( 'pop.email.edu');
$op=new CGI;
print $op->header;
$username=$op->param('username');
$password=$op->param('password');
$t=$server->login($username, $password1);
if($t eq '0')
 {
   print "success";
 }
 else
 {
   print "Failed";
 }

Above code works fine is users password doesn't have any special characters in it.

eg: abcdefg

but when a user have a password with special character it fails

eg: abc%%%_rty

Is there a way i can escape this special characters in password. or is there any other work around in it.

Thank you.
 
I tried something like this

$password="\Q$password\E";

Didn't work. Is there any other good perl module to check user authentication through IMAP.

Thanks
 
Have you tried
$password = quotemeta($password);
This will backslash any non-"word" characters in the password. For your example, this would be abc\%\%\%_rty.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top