This is an automated email from the git hooks/post-receive script.

gregoa pushed a commit to branch master
in repository libscrappy-perl.

commit 2fe82033ec0e0ce6733f43a46743ba3356895616
Author: gregor herrmann <gre...@debian.org>
Date:   Wed May 7 17:00:51 2014 +0200

    Add patches from Lubomir Rintel <lkund...@v3.sk>.
    
    Git-Dch: Ignore
---
 debian/patches/moose-initializers.patch | 35 +++++++++++++
 debian/patches/scraper-control.patch    | 90 +++++++++++++++++++++++++++++++++
 debian/patches/series                   |  2 +
 3 files changed, 127 insertions(+)

diff --git a/debian/patches/moose-initializers.patch 
b/debian/patches/moose-initializers.patch
new file mode 100644
index 0000000..841476b
--- /dev/null
+++ b/debian/patches/moose-initializers.patch
@@ -0,0 +1,35 @@
+Subject: Plugins: Call initializers in correct order
+
+According to Class::MOP::Attribute manual:
+
+Note that there is no guarantee that attributes are initialized in any
+particular order, so you cannot rely on the value of some other attribute when
+generating the default.
+
+This is exactly what was being done, causing test failures ever since hash key
+order was randomized (RT#82142):
+
+Can't use an undefined value as an ARRAY reference at lib/Scrappy/Plugin.pm 
line 21.
+
+Let's just initialize plugins() lazily -- it will still be initialized upon the
+instance creation, since registry() will trigger it, just in the correct order
+now.
+
+From: Lubomir Rintel <lkund...@v3.sk>
+Forwarded: https://rt.cpan.org/Ticket/Display.html?id=82142#txn-1359672
+Bug: https://rt.cpan.org/Public/Bug/Display.html?id=82142#txn-1359672
+
+--- a/lib/Scrappy/Plugin.pm
++++ b/lib/Scrappy/Plugin.pm
+@@ -31,8 +31,10 @@
+ has plugins => (
+     is      => 'ro',
+     isa     => 'Any',
++    # registry() uses us in their initializer, defer our own
++    # initialization until then
++    lazy    => 1,
+     default => sub {
+-
+         my @plugins = ();
+ 
+         # fix for bug found by Patrick Woo
diff --git a/debian/patches/scraper-control.patch 
b/debian/patches/scraper-control.patch
new file mode 100644
index 0000000..86b352b
--- /dev/null
+++ b/debian/patches/scraper-control.patch
@@ -0,0 +1,90 @@
+Subject: Fix Scrapy::Scraper::Control and its test
+
+It's rather broken, possibly due to some careless copy & pasting:
+
+* in restrict() and allow(), "next" outside loops is used in place
+  of function returns
+* in is_allowed(), argument is assumed to be an URI instance despite the
+  function takes a string. Also, a chunk of code (apparently copied from
+  lines above), mistakes allowed() for restricted() and apart from that
+  leaves the logic reversed.
+* Moreover, the test does not pass a valid URI to a subroutine that
+  expects one
+
+The silly condition is left as entertainment for future generations:
+
+     if (keys %{$self->restricted}) {
+         if (keys %{$self->restricted}) {
+
+From: Lubomir Rintel <lkund...@v3.sk>
+Forwarded: https://rt.cpan.org/Ticket/Display.html?id=95420#txn-1359937
+Bug: https://rt.cpan.org/Ticket/Display.html?id=95420
+
+--- a/lib/Scrappy/Scraper/Control.pm
++++ b/lib/Scrappy/Scraper/Control.pm
+@@ -28,7 +28,7 @@ sub allow {
+ 
+     $target = URI->new($target);
+ 
+-    next
++    return $i
+       unless $target
+           && ("URI::http" eq ref $target || "URI::https" eq ref $target);
+ 
+@@ -49,7 +49,7 @@ sub restrict {
+ 
+     $target = URI->new($target);
+ 
+-    next
++    return $i
+       unless $target
+           && ("URI::http" eq ref $target || "URI::https" eq ref $target);
+ 
+@@ -79,6 +79,7 @@ sub is_allowed {
+         $url  = $url->request->uri;
+     }
+ 
++    $url = URI->new($url);
+     return 0 unless ("URI::http" eq ref $url || "URI::https" eq ref $url);
+ 
+     $url = $url->host;
+@@ -107,19 +108,18 @@ sub is_allowed {
+     # is it explicitly restricted
+     if (keys %{$self->restricted}) {
+         if (keys %{$self->restricted}) {
+-
+             # return 0 if $self->restricted->{$url};
+             if ($self->restricted->{$url}) {
+                 if ($self->restricted->{$url}->{if}) {
+-                    return $self->_check_constraints(
+-                        $self->allowed->{$url}->{if}, $http);
++                    return ! $self->_check_constraints(
++                        $self->restricted->{$url}->{if}, $http);
+                 }
+                 else {
+-                    return 1;
++                    return 0;
+                 }
+             }
+             else {
+-                return 0;
++                return 1;
+             }
+         }
+     }
+diff --git a/t/00_test_function_control.t b/t/00_test_function_control.t
+index 2270d12..7cd3407 100644
+--- a/t/00_test_function_control.t
++++ b/t/00_test_function_control.t
+@@ -13,7 +13,7 @@ ok  $s->control->is_allowed('http://search.cpan.org/recent');
+ ok  
$s->control->is_allowed('http://search.cpan.org/dist/Scrappy/lib/Scrappy.pm');
+ ok  ! $s->control->is_allowed('http://www.google.com/');
+ ok  0 == keys %{$s->control->restricted}; # no restriction rules set
+-ok  $s->control->restrict('search.cpan.org');
++ok  $s->control->restrict('http://search.cpan.org');
+ ok  ! $s->control->is_allowed('http://search.cpan.org/');
+ ok  ! $s->control->is_allowed('http://search.cpan.org/recent');
+ ok  ! 
$s->control->is_allowed('http://search.cpan.org/dist/Scrappy/lib/Scrappy.pm');
+-- 
+1.9.0
+
diff --git a/debian/patches/series b/debian/patches/series
index 38edaa7..2dc2962 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,3 @@
 spelling-errors.patch
+moose-initializers.patch
+scraper-control.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-perl/packages/libscrappy-perl.git

_______________________________________________
Pkg-perl-cvs-commits mailing list
Pkg-perl-cvs-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits

Reply via email to