From 845e966c37756121c447fe47ee80aec456106528 Mon Sep 17 00:00:00 2001 From: Thomas Sibley Date: Sat, 19 May 2012 18:43:14 -0400 Subject: [PATCH] Filter::Regexp now works on each entry as intended Encode::decode overwrites the source string when FB_CROAK is used as the CHECK flag. This sets the 'regex' config value to an empty string after processing the first entry, which means the regex never runs on subsequent entries. Adding LEAVE_SRC to the CHECK flag ensures the plugin's config data isn't touched. --- lib/Plagger/Plugin/Filter/Regexp.pm | 2 +- t/plugins/Filter-Regexp/base.t | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Plagger/Plugin/Filter/Regexp.pm b/lib/Plagger/Plugin/Filter/Regexp.pm index 5f141f1d..a4d73777 100644 --- a/lib/Plagger/Plugin/Filter/Regexp.pm +++ b/lib/Plagger/Plugin/Filter/Regexp.pm @@ -17,7 +17,7 @@ sub filter { my($self, $body) = @_; local $_ = $body; - my $regexp = decode_utf8($self->conf->{regexp}, Encode::FB_CROAK); + my $regexp = decode_utf8($self->conf->{regexp}, Encode::FB_CROAK | Encode::LEAVE_SRC); my $count = eval $regexp; if ($@) { diff --git a/t/plugins/Filter-Regexp/base.t b/t/plugins/Filter-Regexp/base.t index 149da6a5..f0b7edd7 100644 --- a/t/plugins/Filter-Regexp/base.t +++ b/t/plugins/Filter-Regexp/base.t @@ -15,9 +15,12 @@ plugins: entry: - title: bar body: Plagger + - title: baz + body: Plagger, she said. - module: Filter::Regexp config: regexp: s/Plagger/Plagger is a pluggable aggregator/g text_only: 1 --- expected -is $context->update->feeds->[0]->entries->[0]->body, "Plagger is a pluggable aggregator" +is $context->update->feeds->[0]->entries->[0]->body, "Plagger is a pluggable aggregator"; +is $context->update->feeds->[0]->entries->[1]->body, "Plagger is a pluggable aggregator, she said.";