Bug 106228 - Unrecognised line from perl module Valid.pm
Summary: Unrecognised line from perl module Valid.pm
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: perl
Version: 9
Hardware: i686
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jason Vas Dias
QA Contact: David Lawrence
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2003-10-03 19:53 UTC by Neil Watson
Modified: 2007-04-18 16:58 UTC (History)
0 users

Fixed In Version: ALL
Clone Of:
Environment:
Last Closed: 2005-11-11 23:40:34 UTC
Embargoed:


Attachments (Terms of Use)

Description Neil Watson 2003-10-03 19:53:15 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5a) Gecko/20030728
Mozilla Firebird/0.6.1

Description of problem:
Running Perl 5.8.0 Email::Valid v 0.15 and Email::Valid::Loose 0.02 on Redhat 9.

Test code:

#!/usr/bin/perl

use strict;
use warnings;

use Email::Valid::Loose;

my ($add, @adds);

my $addrfile = $ARGV[0] || die "filename not given";

open (EMAILS, "$addrfile");

#remove troublesome windows /r characters
#and whitespace
 while (<EMAILS>){
    chomp $_;
    $_ =~ s/\015//;
    $_ =~ s/\s//g;
    push @adds, $_;
}
close (EMAILS);

foreach $add (@adds){

    #if email is invalid move on
    if (!defined(Email::Valid::Loose->address($add))){
        print $add." is a bad address\n"; #address is bad
    }else{
        print $add." is a good address\n"; #address is good
    }
}

Test file:

user1
user2
user3


The error:

Unrecognised line: user1 at /usr/lib/perl5/site_perl/5.8.0/Email/Valid.pm
line 232


This code does work on Mandrake 8.1 (perl 5.6.1) Gentoo 1.4 (same versions as
above) and Redhat 6.2.

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. See sample code in description    

Additional info:

Comment 1 Paulo Matos 2004-04-28 11:00:00 UTC
Another description of the problem on an entire different setup:
http://www.nntp.perl.org/group/perl.qpsmtpd/1226

Just for the record, the cause and solution:

Mail::Address->parse($email) caused an the error (croaks):

Unrecognised line: 'foo'

Well, it seems that perl 5.8.0-5.8.? has several problems with utf8.

The internal representation of perl strings has an UTF-8 flag associated 
that can be turned off via Encode::_utf8_off($string), so a way to solve 
some issues like this are to use this workaround. (see Encode 
documentation for more details).

I saw postings refering that the problem may be cause by using perl with 
thread support, which is not the case I tested it under perl with and 
without thread support with the same results. (The stock perl shipped
with 
some distros are threaded enabled: e.g. RedHat 9, RHEL, WBEL...)

A generic workaround to cases like this would be to use: 

Encode:_utf8_off($parameter_variable);

before calling the problematic function, which in this case is 
Mail::Address->parse().

This has to be used with caution since it messes with perl internals,
so sometimes you'll have to switch the flag on after calling the function.



Comment 2 Jason Vas Dias 2005-11-11 23:40:34 UTC
Very sorry for the long delay in processing this bug report.
This bug is no longer a problem with the perl in any current Red Hat OS.


Note You need to log in before you can comment on or make changes to this bug.