Skip Menu |

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

Report information
The Basics
Id: 131967
Status: rejected
Priority: 0/
Queue: URI-XS

People
Owner: Nobody in particular
Requestors: asan999 [...] gmail.com
Cc:
AdminCc:

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



Subject: The parser behavior has changed
Date: Tue, 25 Feb 2020 15:51:54 +0300
To: bug-URI-XS [...] rt.cpan.org
From: Andrey Asyakin <asan999 [...] gmail.com>
Hello! my $uri = URI::XS->new("http://example.com/?foo[bar]=12"); $uri is undefined. Yes, the parameter name does not comply with the standard. But, this behavior is different from the behavior Panda::URI and URI. This seems to be a bug. Best regards, Andrey.
Втр Фев 25 07:52:14 2020, asan999@gmail.com писал: Show quoted text
> Hello! > > my $uri = URI::XS->new("http://example.com/?foo[bar]=12"); > $uri is undefined. > > Yes, the parameter name does not comply with the standard. > But, this behavior is different from the behavior Panda::URI and URI. This > seems to be a bug. > > Best regards, > Andrey.
Hello, Andrey) No it's not a bug. In the latest version of URI::XS parser has been completely rewritten and now using generated FSM. The new parser is fully RFC-compliant, while URI.pm and the old parser are not. The uri example you listed is ill-formed, do not use such URIs. If you've got to deal with such URIs (for example, if you're getting it from remote partners), you can make a wrapper that deals with it, for example sub new_uri_permissive { my $str = shift; $str =~ s/\[/%5B/g; $str =~ s/\]/%5D/g; return URI::uri($str); } or for better performance sub new_uri_permissive { my $str = shift; my $ret = URI::uri($str); unless ($ret) { $str =~ s/\[/%5B/g; $str =~ s/\]/%5D/g; $ret = URI::uri($str); } return $ret; } or package MyPermissiveURI; use base 'URI::XS'; use 5.012; sub new { my $class = shift; my $self = $class->SUPER::new(@_); if (!$self && !ref($_[0]) { my $str = shift; $str =~ s/\[/%5B/g; $str =~ s/\]/%5D/g; $self = $class->SUPER::new($str, @_); } return $self; }