Subject: | IPv6 string literals in host field fail - with patch |
Thanks for the module - it works great. However, I've been looking at IPv6 and according to RFC 2732, IPv6 addresses can be used in URI; however, they must be enclosed in brackets []s since they are colon separated and this can be an issue with a trailing port number specified.
You use two regex for decoding URI - 'strict' and 'loose'. My patch updates the 'loose' to allow IPv6 string literals according to RFC 2732 to be found and separated from the URI. Alternatively, you could add another regex, but you'd need to slightly update the API call for new(URI,isStrict) so isStrict wouldn't be a flag to enable loose, but a regex name for the one to use. Your call; my patch just updates the existing 'loose' regex.
Also note I put in a similar pull request on GitHub:
https://github.com/mamod/URI-Simple/pull/1
Cheers.
Subject: | Simple.pm.patch |
--- lib\URI\Simple.pm 2013-05-27 16:33:14.000000000 -0400
+++ ..\..\tmp\URI-Simple-1.01\lib\URI\Simple.pm 2017-10-05 12:39:52.216085800 -0400
@@ -17,8 +17,9 @@
parser => {
strict => qr/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
- loose => qr/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
- }
+ # New 'loose' to address IPv6 literals in URI (RFC 2732)
+ loose => qr/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:\[[a-fA-F0-9:]*\])|(?:[^:\/?#]*)?)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
+ } #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
};
#==========================================================================