Skip Menu |
 

This queue is for tickets about the URI CPAN distribution.

Report information
The Basics
Id: 73813
Status: rejected
Priority: 0/
Queue: URI

People
Owner: Nobody in particular
Requestors: wyant [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Wishlist: non-global way to turn on URI::URL strictness
Download (untitled) / with headers
text/plain 1.1k
It would be handy for those using URI::URL to validate URLs if there were a non-global alternative to URI::URL::strict(). As things stand, validation without action at a distance seems to involve code like my $old_strict = URI::URL::strict( 1 ); my $obj = eval { URI::URL->new( $url ); } or do { URI::URL::strict( $old_strict ); die $@; # Re-raise exception }; URI::URL::strict( $old_strict ); There are a number of ways to get what I would like. The following list is off the top of my head, and is in no particular order, though I think if I could have anything I wanted, I would actually prefer the last suggestion. Documenting $URI::URL::STRICT would allow the strictness to be localized, and reduce the above code to my $obj = do { local $URI::URL::STRICT = 1; URI::URL->new( $url ); }; Making it an argument to new() would also be okay, making the code something like my $obj = URI::URL->new( $url, strict => 1 ); Yet another acceptable alternative would be an is_known_scheme() method on the returned object, which (speaking in terms of the internals, assuming I understand them) returns a false value for URI::_foreign objects, and a true value for anything else.
On Sat Jan 07 12:56:35 2012, WYANT wrote:
Show quoted text
> Documenting $URI::URL::STRICT would allow the strictness to be
> localized, and reduce the above code to
>
> my $obj = do {
> local $URI::URL::STRICT = 1;
> URI::URL->new( $url );
> };

This already works.  The URI::URL module is deprecated.  If you feel enough about this to provide a documentation patch I'm happy to apply it.  I don't want to change the code at all.

You should migrate your code to use the regular URI class instead.

On Sun Mar 11 11:53:36 2012, GAAS wrote: Show quoted text
> On Sat Jan 07 12:56:35 2012, WYANT wrote:
> > Documenting $URI::URL::STRICT would allow the strictness to be > > localized, and reduce the above code to > > > > my $obj = do { > > local $URI::URL::STRICT = 1; > > URI::URL->new( $url ); > > };
> > This already works. The URI::URL module is deprecated. If you feel > enough about > this to provide a documentation patch I'm happy to apply it. I don't > want to > change the code at all. > > You should migrate your code to use the regular URI class instead.
Thank you for your response. Given URI::URL's deprecation, I'm inclined retract the ticket. My apologies for the wasted motion on your part. What actually happened is that after a while I realized the question I wanted answered was not "is this URL valid?" but "can I actually pass this URL to LWP::UserAgent and have a chance of getting something back?" Once I came to this understanding of what I was trying to do, the answer had nothing to do with URI (at least not directly), but with LWP::Protocol::implementor().


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.