diff -Nru libdata-validate-uri-perl-0.06/Changes libdata-validate-uri-perl-0.07/Changes --- libdata-validate-uri-perl-0.06/Changes 2012-02-12 18:38:27.000000000 +0000 +++ libdata-validate-uri-perl-0.07/Changes 2016-01-19 16:34:41.000000000 +0000 @@ -1,5 +1,8 @@ Revision history for Perl extension Data::Validate::URI +0.07 20160119 + - Adding Josef Toman's underscore patch + 0.06 20120211 - Adding David Dick's is_tel_uri patch diff -Nru libdata-validate-uri-perl-0.06/debian/changelog libdata-validate-uri-perl-0.07/debian/changelog --- libdata-validate-uri-perl-0.06/debian/changelog 2012-03-18 21:38:12.000000000 +0000 +++ libdata-validate-uri-perl-0.07/debian/changelog 2017-08-26 13:35:49.000000000 +0000 @@ -1,3 +1,15 @@ +libdata-validate-uri-perl (0.07-1) unstable; urgency=medium + + * Switch Maintainer to Debian Perl Group + * debian/watch: use metacpan-based URL. + * debian/control: Changed: Homepage field changed to metacpan.org URL. + * Update debhelper compat level to 9 + * Update Standards-Version (no changes) + * Switch to machine-readable copyright format + * New upstream release + + -- Dominic Hargreaves Sat, 26 Aug 2017 14:35:47 +0100 + libdata-validate-uri-perl (0.06-1) unstable; urgency=low * Add Vcs-* URLs diff -Nru libdata-validate-uri-perl-0.06/debian/compat libdata-validate-uri-perl-0.07/debian/compat --- libdata-validate-uri-perl-0.06/debian/compat 2012-03-18 21:36:47.000000000 +0000 +++ libdata-validate-uri-perl-0.07/debian/compat 2017-08-26 13:31:58.000000000 +0000 @@ -1 +1 @@ -8 +9 diff -Nru libdata-validate-uri-perl-0.06/debian/control libdata-validate-uri-perl-0.07/debian/control --- libdata-validate-uri-perl-0.06/debian/control 2012-03-18 21:37:15.000000000 +0000 +++ libdata-validate-uri-perl-0.07/debian/control 2017-08-26 13:31:58.000000000 +0000 @@ -1,11 +1,12 @@ Source: libdata-validate-uri-perl Section: perl Priority: optional -Build-Depends: debhelper (>= 8) +Build-Depends: debhelper (>= 9) Build-Depends-Indep: perl (>= 5.6.10-12), libdata-validate-domain-perl, libdata-validate-ip-perl -Maintainer: Dominic Hargreaves -Standards-Version: 3.9.3 -Homepage: http://search.cpan.org/dist/Data-Validate-URI/ +Maintainer: Debian Perl Group +Uploaders: Dominic Hargreaves +Standards-Version: 4.1.0 +Homepage: https://metacpan.org/release/Data-Validate-URI Vcs-Git: git://anonscm.debian.org/users/dom/libdata-validate-uri-perl.git Vcs-Browser: http://anonscm.debian.org/gitweb/?p=users/dom/libdata-validate-uri-perl.git diff -Nru libdata-validate-uri-perl-0.06/debian/copyright libdata-validate-uri-perl-0.07/debian/copyright --- libdata-validate-uri-perl-0.06/debian/copyright 2012-03-18 21:19:02.000000000 +0000 +++ libdata-validate-uri-perl-0.07/debian/copyright 2017-08-26 13:31:58.000000000 +0000 @@ -1,27 +1,32 @@ -This is the debian package for the Data-Validate-URI module. -It was created by Dominic Hargreaves using dh-make-perl. - -It was downloaded from http://search.cpan.org/dist/Data-Validate-URI/ - -The upstream author is: Richard Sonnen (sonnen@richardsonnen.com). - -Copyright (c) 2005 Richard Sonnen. All rights reserved. - -This program is free software; you can redistribute it and/or modify -it under the same terms as Perl itself. - -t/ExtUtils/TBone.pm: - -Copyright (c) 1996 by Eryq. All rights reserved. -Copyright (c) 1999 by ZeeGee Software Inc. All rights reserved. - -This program is free software; you can redistribute it and/or modify -it under the same terms as Perl itself. - -Perl is distributed under your choice of the GNU General Public License or -the Artistic License. On Debian GNU/Linux systems, the complete text of the -GNU General Public License can be found in `/usr/share/common-licenses/GPL' -and the Artistic Licence in `/usr/share/common-licenses/Artistic'. - -The Debian packaging is (C) 2008, Dominic Hargreaves and -is licensed under the same terms as the software itself (see above). +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Source: https://metacpan.org/release/Data-Validate-URI +Upstream-Contact: Richard Sonnen +Upstream-Name: Data-Validate-URI + +Files: * +Copyright: 2005 Richard Sonnen +License: Artistic or GPL-1+ + +Files: t/ExtUtils/TBone.pm +Copyright: 1999 by ZeeGee Software Inc, 1996 by Eryq +License: Artistic or GPL-1+ + +Files: debian/* +Copyright: 2008-2017, Dominic Hargreaves +License: Artistic or GPL-1+ + +License: Artistic + This program is free software; you can redistribute it and/or modify + it under the terms of the Artistic License, which comes with Perl. + . + On Debian systems, the complete text of the Artistic License can be + found in `/usr/share/common-licenses/Artistic'. + +License: GPL-1+ + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + . + On Debian systems, the complete text of version 1 of the GNU General + Public License can be found in `/usr/share/common-licenses/GPL-1'. diff -Nru libdata-validate-uri-perl-0.06/debian/watch libdata-validate-uri-perl-0.07/debian/watch --- libdata-validate-uri-perl-0.06/debian/watch 2012-03-18 21:19:02.000000000 +0000 +++ libdata-validate-uri-perl-0.07/debian/watch 2017-08-26 13:31:58.000000000 +0000 @@ -1,4 +1,4 @@ # format version number, currently 3; this line is compulsory! version=3 # URL to the package page followed by a regex to search -http://search.cpan.org/dist/Data-Validate-URI/ .*/Data-Validate-URI-v?(\d[\d_.-]+)\.(?:tar(?:\.gz|\.bz2)?|tgz|zip)$ +https://metacpan.org/release/Data-Validate-URI .*/Data-Validate-URI-v?(\d[\d.-]+)\.(?:tar(?:\.gz|\.bz2)?|tgz|zip)$ diff -Nru libdata-validate-uri-perl-0.06/lib/Data/Validate/URI.pm libdata-validate-uri-perl-0.07/lib/Data/Validate/URI.pm --- libdata-validate-uri-perl-0.06/lib/Data/Validate/URI.pm 2012-02-12 18:36:40.000000000 +0000 +++ libdata-validate-uri-perl-0.07/lib/Data/Validate/URI.pm 2016-01-19 14:26:33.000000000 +0000 @@ -26,7 +26,7 @@ %EXPORT_TAGS = (); -$VERSION = '0.06'; +$VERSION = '0.07'; # No preloads @@ -84,7 +84,7 @@ =item B - constructor for OO usage - new(); + new(%options); =over 4 @@ -96,7 +96,13 @@ =item I -None +=over 4 + +=item %options + +Options to be passed into the underlying Data::Validate::Domain module + +=back =item I @@ -109,7 +115,7 @@ sub new{ my $class = shift; - return bless {}, $class; + return bless {@_}, $class; } # ------------------------------------------------------------------------------- @@ -202,11 +208,66 @@ # ------------------------------------------------------------------------------- +sub _test_uri { + # 1 = HTTP only + # 2 = HTTPS only + # 3 = both HTTP and HTTPS are allowed + my $allowed_scheme = shift; + my $value = shift; + my $options = shift // {}; + + return unless is_uri($value); + + my($scheme, $authority, $path, $query, $fragment) = _split_uri($value); + + return unless $scheme; + + if($allowed_scheme == 1) { + return unless lc($scheme) eq 'http'; + } elsif ($allowed_scheme == 2) { + return unless lc($scheme) eq 'https' + } elsif ($allowed_scheme == 3) { + return unless lc($scheme) =~ m/^https?$/; + } else { + return; + } + + # fully-qualified URIs must have an authority section that is + # a valid host + return unless($authority); + + # allow a port component + my($port) = $authority =~ /:(\d+)$/; + $authority =~ s/:\d+$//; + + # modifying this to allow the (discouraged, but still legal) use of IP addresses + unless(Data::Validate::Domain::is_domain($authority, $options) || Data::Validate::IP::is_ipv4($authority)){ + return; + } + + # re-assemble the URL per section 5.3 in RFC 3986 + my $out = $scheme . ':'; + $out .= '//' . $authority; + + $out .= ':' . $port if $port; + + $out .= $path; + + if(defined $query && length($query)){ + $out .= '?' . $query; + } + if(defined $fragment && length($fragment)){ + $out .= '#' . $fragment; + } + + return $out; +} + =pod =item B - is the value a well-formed HTTP uri? - is_http_uri($value); + is_http_uri($value, \%options); =over 4 @@ -229,7 +290,8 @@ print "Good" if(is_http_uri($uri) || is_https_uri($uri)); -or use the convenience method is_web_uri which is equivalent. +or use the convenience method is_web_uri which is equivalent and faster, because +it does the work only once. =item I @@ -239,6 +301,11 @@ The potential URI to test. +=item \%options + +Options to be passed into the underlying Data::Validate::Domain module. If +called as a method, the options are ignored. + =back =item I @@ -256,52 +323,11 @@ =cut sub is_http_uri{ - my $self = shift if ref($_[0]); + my $self = shift if ref($_[0]); my $value = shift; - my $allow_https = shift; - - return unless is_uri($value); - - my($scheme, $authority, $path, $query, $fragment) = _split_uri($value); - - return unless $scheme; - - if($allow_https){ - return unless lc($scheme) eq 'https'; - } else { - return unless lc($scheme) eq 'http'; - } - - # fully-qualified URIs must have an authority section that is - # a valid host - return unless($authority); - - # allow a port component - my($port) = $authority =~ /:(\d+)$/; - $authority =~ s/:\d+$//; - - # modifying this to allow the (discouraged, but still legal) use of IP addresses - unless(Data::Validate::Domain::is_domain($authority) || Data::Validate::IP::is_ipv4($authority)){ - return; - } - - # re-assemble the URL per section 5.3 in RFC 3986 - my $out = $scheme . ':'; - $out .= '//' . $authority; - - $out .= ':' . $port if $port; - - $out .= $path; - - if(defined $query && length($query)){ - $out .= '?' . $query; - } - if(defined $fragment && length($fragment)){ - $out .= '#' . $fragment; - } - - return $out; - + $self //= shift; + + return _test_uri(1, $value, $self); } @@ -311,7 +337,7 @@ =item B - is the value a well-formed HTTPS uri? - is_https_uri($value); + is_https_uri($value. \%options); =over 4 @@ -328,6 +354,11 @@ The potential URI to test. +=item \%options + +Options to be passed into the underlying Data::Validate::Domain module. If +called as a method, the options are ignored. + =back =item I @@ -347,8 +378,9 @@ sub is_https_uri{ my $self = shift if ref($_[0]); my $value = shift; + $self //= shift; - return is_http_uri($value, 1); + return _test_uri(2, $value, $self); } @@ -358,14 +390,15 @@ =item B - is the value a well-formed HTTP or HTTPS uri? - is_web_uri($value); + is_web_uri($value, \%options); =over 4 =item I This is just a convinience method that combines is_http_uri and is_https_uri -to accept most common real-world URLs. +to accept most common real-world URLs. But it's faster, because it does the +work only once. =item I @@ -375,6 +408,11 @@ The potential URI to test. +=item \%options + +Options to be passed into the underlying Data::Validate::Domain module. If +called as a method, the options are ignored. + =back =item I @@ -394,11 +432,9 @@ sub is_web_uri{ my $self = shift if ref($_[0]); my $value = shift; - - my $h = is_http_uri($value); - return $h if defined $h; - - return is_https_uri($value); + $self //= shift; + + return _test_uri(3, $value, $self); } # ------------------------------------------------------------------------------- diff -Nru libdata-validate-uri-perl-0.06/META.yml libdata-validate-uri-perl-0.07/META.yml --- libdata-validate-uri-perl-0.06/META.yml 2012-02-12 18:38:40.000000000 +0000 +++ libdata-validate-uri-perl-0.07/META.yml 2016-01-19 11:51:40.000000000 +0000 @@ -1,6 +1,6 @@ --- #YAML:1.0 name: Data-Validate-URI -version: 0.06 +version: 0.07 abstract: ~ author: - Richard Sonnen (sonnen@richardsonnen.com) diff -Nru libdata-validate-uri-perl-0.06/t/is_https_uri.t libdata-validate-uri-perl-0.07/t/is_https_uri.t --- libdata-validate-uri-perl-0.06/t/is_https_uri.t 2007-11-25 20:56:05.000000000 +0000 +++ libdata-validate-uri-perl-0.07/t/is_https_uri.t 2016-01-19 14:09:00.000000000 +0000 @@ -14,9 +14,16 @@ my $t = ExtUtils::TBone->typical(); -$t->begin(13); +$t->begin(17); $t->msg("testing is_https_uri..."); +# invalid +$t->ok(!defined(is_https_uri('')), "bad: ''"); +$t->ok(!defined(is_https_uri('http://www.richardsonnen.com/')), 'http://www.richardsonnen.com/'); +$t->ok(!defined(is_https_uri('ftp://ftp.richardsonnen.com')), "bad: 'ftp://ftp.richardsonnen.com'"); +$t->ok(!defined(is_https_uri('https:www.richardsonnen.com')), "bad: 'https:www.richardsonnen.com'"); +$t->ok(!defined(is_https_uri('https://under_scored.richardsonnen.com/')), "bad: 'https://under_scored.richardsonnen.com/'"); + # valid $t->ok(defined(is_https_uri('https://www.richardsonnen.com/')), 'https://www.richardsonnen.com/'); $t->ok(defined(is_https_uri('https://www.richardsonnen.com')), 'https://www.richardsonnen.com'); @@ -25,17 +32,15 @@ $t->ok(defined(is_https_uri('https://www.richardsonnen.com:8080/test.html')), 'https://www.richardsonnen.com:8080/test.html'); $t->ok(defined(is_https_uri('https://example.w3.org/path%20with%20spaces.html')), 'http://example.w3.org/path%20with%20spaces.html'); $t->ok(defined(is_https_uri('https://192.168.0.1/')), 'http://192.168.0.1/'); - -# invalid -$t->ok(!defined(is_https_uri('')), "bad: ''"); -$t->ok(!defined(is_https_uri('http://www.richardsonnen.com/')), 'http://www.richardsonnen.com/'); -$t->ok(!defined(is_https_uri('ftp://ftp.richardsonnen.com')), "bad: 'ftp://ftp.richardsonnen.com'"); -$t->ok(!defined(is_https_uri('https:www.richardsonnen.com')), "bad: 'https:www.richardsonnen.com'"); +$t->ok(defined(is_https_uri('https://under_scored.richardsonnen.com/', {domain_allow_underscore=>1})), 'https://under_scored.richardsonnen.com/'); # as an object my $v = Data::Validate::URI->new(); $t->ok(defined($v->is_https_uri('https://www.richardsonnen.com/')), 'https://www.richardsonnen.com/ (object)'); $t->ok(!defined($v->is_https_uri('foo')), 'bad: foo (object)'); +$t->ok(!defined($v->is_https_uri('https://under_scored.richardsonnen.com/')), "bad: 'https://under_scored.richardsonnen.com/' (object)"); +$v = Data::Validate::URI->new(domain_allow_underscore=>1); +$t->ok(defined($v->is_https_uri('https://under_scored.richardsonnen.com/')), 'https://under_scored.richardsonnen.com/ (object)'); # we're done $t->end(); diff -Nru libdata-validate-uri-perl-0.06/t/is_http_uri.t libdata-validate-uri-perl-0.07/t/is_http_uri.t --- libdata-validate-uri-perl-0.06/t/is_http_uri.t 2007-11-25 20:55:36.000000000 +0000 +++ libdata-validate-uri-perl-0.07/t/is_http_uri.t 2016-01-19 14:09:05.000000000 +0000 @@ -14,9 +14,16 @@ my $t = ExtUtils::TBone->typical(); -$t->begin(13); +$t->begin(17); $t->msg("testing is_http_uri..."); +# invalid +$t->ok(!defined(is_http_uri('')), "bad: ''"); +$t->ok(!defined(is_http_uri('ftp://ftp.richardsonnen.com')), "bad: 'ftp://ftp.richardsonnen.com'"); +$t->ok(!defined(is_http_uri('http:www.richardsonnen.com')), "bad: 'http:www.richardsonnen.com'"); +$t->ok(!defined(is_http_uri('https://www.richardsonnen.com')), "bad: 'https://www.richardsonnen.com'"); +$t->ok(!defined(is_http_uri('http://under_scored.richardsonnen.com/')), "bad: 'http://under_scored.richardsonnen.com/'"); + # valid $t->ok(defined(is_http_uri('http://www.richardsonnen.com/')), 'http://www.richardsonnen.com/'); $t->ok(defined(is_http_uri('http://www.richardsonnen.com')), 'http://www.richardsonnen.com'); @@ -25,17 +32,15 @@ $t->ok(defined(is_http_uri('http://www.richardsonnen.com:8080/test.html')), 'http://www.richardsonnen.com:8080/test.html'); $t->ok(defined(is_http_uri('http://example.w3.org/path%20with%20spaces.html')), 'http://example.w3.org/path%20with%20spaces.html'); $t->ok(defined(is_http_uri('http://192.168.0.1/')), 'http://192.168.0.1/'); - -# invalid -$t->ok(!defined(is_http_uri('')), "bad: ''"); -$t->ok(!defined(is_http_uri('ftp://ftp.richardsonnen.com')), "bad: 'ftp://ftp.richardsonnen.com'"); -$t->ok(!defined(is_http_uri('http:www.richardsonnen.com')), "bad: 'http:www.richardsonnen.com'"); -$t->ok(!defined(is_http_uri('https://www.richardsonnen.com')), "bad: 'https://www.richardsonnen.com'"); +$t->ok(defined(is_http_uri('http://under_scored.richardsonnen.com/', {domain_allow_underscore=>1})), 'https://under_scored.richardsonnen.com/'); # as an object my $v = Data::Validate::URI->new(); $t->ok(defined($v->is_http_uri('http://www.richardsonnen.com/')), 'http://www.richardsonnen.com/ (object)'); $t->ok(!defined($v->is_http_uri('foo')), 'bad: foo (object)'); +$t->ok(!defined($v->is_http_uri('http://under_scored.richardsonnen.com/')), "bad: 'http://under_scored.richardsonnen.com/' (object)"); +$v = Data::Validate::URI->new(domain_allow_underscore=>1); +$t->ok(defined($v->is_http_uri('http://under_scored.richardsonnen.com/')), 'http://under_scored.richardsonnen.com/ (object)'); # we're done $t->end(); diff -Nru libdata-validate-uri-perl-0.06/t/is_web_uri.t libdata-validate-uri-perl-0.07/t/is_web_uri.t --- libdata-validate-uri-perl-0.06/t/is_web_uri.t 2007-11-25 20:56:19.000000000 +0000 +++ libdata-validate-uri-perl-0.07/t/is_web_uri.t 2016-01-19 14:15:00.000000000 +0000 @@ -14,9 +14,17 @@ my $t = ExtUtils::TBone->typical(); -$t->begin(18); +$t->begin(26); $t->msg("testing is_web_uri..."); +# invalid +$t->ok(!defined(is_web_uri('')), "bad: ''"); +$t->ok(!defined(is_web_uri('ftp://ftp.richardsonnen.com')), "bad: 'ftp://ftp.richardsonnen.com'"); +$t->ok(!defined(is_web_uri('https:www.richardsonnen.com')), "bad: 'http:www.richardsonnen.com'"); +$t->ok(!defined(is_web_uri('http:www.richardsonnen.com')), "bad: 'http:www.richardsonnen.com'"); +$t->ok(!defined(is_web_uri('http://under_scored.richardsonnen.com/')), "bad: 'http://under_scored.richardsonnen.com/'"); +$t->ok(!defined(is_web_uri('https://under_scored.richardsonnen.com/')), "bad: 'https://under_scored.richardsonnen.com/'"); + # valid $t->ok(defined(is_web_uri('https://www.richardsonnen.com/')), 'https://www.richardsonnen.com/'); $t->ok(defined(is_web_uri('https://www.richardsonnen.com')), 'https://www.richardsonnen.com'); @@ -30,17 +38,18 @@ $t->ok(defined(is_web_uri('http://www.richardsonnen.com:8080/test.html')), 'http://www.richardsonnen.com:8080/test.html'); $t->ok(defined(is_web_uri('http://example.w3.org/path%20with%20spaces.html')), 'http://example.w3.org/path%20with%20spaces.html'); $t->ok(defined(is_web_uri('http://192.168.0.1/')), 'http://192.168.0.1/'); - -# invalid -$t->ok(!defined(is_web_uri('')), "bad: ''"); -$t->ok(!defined(is_web_uri('ftp://ftp.richardsonnen.com')), "bad: 'ftp://ftp.richardsonnen.com'"); -$t->ok(!defined(is_web_uri('https:www.richardsonnen.com')), "bad: 'http:www.richardsonnen.com'"); -$t->ok(!defined(is_web_uri('http:www.richardsonnen.com')), "bad: 'http:www.richardsonnen.com'"); +$t->ok(defined(is_web_uri('http://under_scored.richardsonnen.com/', {domain_allow_underscore=>1})), 'http://under_scored.richardsonnen.com/'); +$t->ok(defined(is_web_uri('https://under_scored.richardsonnen.com/', {domain_allow_underscore=>1})), 'https://under_scored.richardsonnen.com/'); # as an object my $v = Data::Validate::URI->new(); $t->ok(defined($v->is_web_uri('http://www.richardsonnen.com/')), 'http://www.richardsonnen.com/ (object)'); $t->ok(!defined($v->is_web_uri('foo')), 'bad: foo (object)'); +$t->ok(!defined($v->is_web_uri('http://under_scored.richardsonnen.com/')), "bad: 'http://under_scored.richardsonnen.com/' (object)"); +$t->ok(!defined($v->is_web_uri('https://under_scored.richardsonnen.com/')), "bad: 'https://under_scored.richardsonnen.com/' (object)"); +$v = Data::Validate::URI->new(domain_allow_underscore=>1); +$t->ok(defined($v->is_web_uri('http://under_scored.richardsonnen.com/')), 'http://under_scored.richardsonnen.com/ (object)'); +$t->ok(defined($v->is_web_uri('https://under_scored.richardsonnen.com/')), 'https://under_scored.richardsonnen.com/ (object)'); # we're done $t->end();