On Thu Sep 22 13:52:26 2011, NICOMEN wrote:
Show quoted text> Fair enough, and I might be barking up the wrong tree. BUT:
>
> $ perl -wle 'use URI; use URI::URL; print URI->new("irc://foo.com/bar")-
> >scheme(); print URI::URL->new("irc://foo.com/bar")->scheme()'
> irc
> irc
>
> so you see they both support IRC urls just fine, maybe it would make
> sense as another ticket says to use the newer URI directly?
This is the earlier problem you identified where strict is off so URI
will accept anything.
$ perl -wle 'use URI::URL; use URI; URI::URL::strict(1); print
URI->new("irc://foo.com/bar")'
Unknown URI::URL scheme irc: at
/Users/schwern/perl5/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/URI/URL.pm
line 42.
Show quoted text> Also, for now I worked around the issue with a subclass:
>
> $ cat lib/MyOpera/URI/Find.pm
> package MyOpera::URI::Find;
>
> use base 'URI::Find';
>
> sub _uri_filter {
> my ($self) = shift;
> my $old_strict = URI::URL::strict(0);
> my $ret = $self->SUPER::_uri_filter(@_);
> URI::URL::strict($old_strict);
> return $ret;
> }
_uri_filter() is private and cannot be relied upon to work or exist.
You'd be better off writing a minimal URI::irc and sticking it in your code.
# First check that URI didn't already add URI::irc
if( !eval { require URI::irc } ) {
# Then define our own
package URI::irc;
require URI::_server;
URI::_server->import;
}
Show quoted text> and in turn:
>
> my $finder = MyOpera::URI::Find->new(
> sub {
> my $url = $_[1];
> return $url unless $url =~ m{ \A (http|https|irc|ftp):// }igmx;
> handle_url($url);
> }
> );
The callback is given a URI object. It's more reliable to ask it what
the scheme is than to use a regex.