Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the URI-Find CPAN distribution.

Report information
The Basics
Id: 71146
Status: resolved
Priority: 0/
Queue: URI-Find

People
Owner: Nobody in particular
Requestors: mendoza [...] pvv.ntnu.no
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 20100505
Fixed in: (no value)



Hi, I can't seem to find irc:// urls, it seems that by turning URI::URI::strict(1) on it doesn't like the irc scheme: Unknown URI::URL scheme irc: at /usr/share/perl5/URI/URL.pm line 42 Just setting it to 0 works like a charm, unfortunately it's hard to override it here since it's force-set inside the find() method. also the comment above the code doesn't make sense to me: # Don't assume http. my $old_strict = URI::URL::strict(1); Is it meant to be 0 originally?
to. 22. sep. 2011 12.51.27 skrev NICOMEN: Show quoted text
> Hi, I can't seem to find irc:// urls, it seems that by turning > URI::URI::strict(1) on it doesn't like the irc scheme: > > Unknown URI::URL scheme irc: at /usr/share/perl5/URI/URL.pm line
42 Show quoted text
> > Just setting it to 0 works like a charm, unfortunately it's hard to > override it here since it's force-set inside the find() method. > > also the comment above the code doesn't make sense to me: > > # Don't assume http. > my $old_strict = URI::URL::strict(1); > > Is it meant to be 0 originally?
Ok, I see that without it it matches on stuff like 'foo:bar'. Should there be some way of adding scheme urls perhaps?
Thanks, irc URLs are important. The simplest way to add schemes, given the current design which just asks URI if a given URL is valid, is to add it to the URI distribution. That is, write URI::irc and patch it into <http://search.cpan.org/dist/URI>. While you're waiting for it to be accepted, if you write and install URI::irc yourself it will be picked up. A minimal version of URI::irc would be just a subclass of URI::_server. Use URI::http for an example. You can go on from there, adding IRC specific methods like target() and modifiers() and further parsing target() into channel() or nick() and so on. Here's the specs for IRC urls that I know of. http://www.w3.org/Addressing/draft-mirashi-url-irc-01.txt http://www-archive.mozilla.org/projects/rt-messaging/chatzilla/irc-urls.html I'm going to close this as there's nothing for URI::Find to do about it. Please reopen if you feel there is. If you want to discuss re-engineering how it determines valid schemes, go ahead an open another ticket.
Subject: irc:// urls not found
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")- Show quoted text
>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? 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; } 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); } );
Oh and thanks for your quick response! ;)
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.