From 823e94693e785c11470d515233e9209ea9a1319f Mon Sep 17 00:00:00 2001 From: Matt Miller Date: Sat, 16 Aug 2014 16:46:37 -0400 Subject: [PATCH] Meta::Helper: concatenate instead of truncate for scalar. Based on input from @mintsoft. I can see how this makes more sense, so I'm on-board, too. --- lib/DDG/Meta/Helper.pm | 4 ++-- t/14-meta-helpers.t | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/DDG/Meta/Helper.pm b/lib/DDG/Meta/Helper.pm index 2f964154..87d1840b 100644 --- a/lib/DDG/Meta/Helper.pm +++ b/lib/DDG/Meta/Helper.pm @@ -37,7 +37,7 @@ encodes entities to safely post random data on HTML output. =cut - $stash->add_symbol('&html_enc', sub { return (wantarray) ? map { encode_entities($_) } @_ : encode_entities($_[0]) }); + $stash->add_symbol('&html_enc', sub { return (wantarray) ? map { encode_entities($_) } @_ : encode_entities(join '', @_) }); =keyword uri_esc @@ -50,7 +50,7 @@ values there, this will just lead to double encoding! =cut - $stash->add_symbol('&uri_esc', sub { return (wantarray) ? map { uri_escape($_) } @_ : uri_escape($_[0]) }); + $stash->add_symbol('&uri_esc', sub { return (wantarray) ? map { uri_escape($_) } @_ : uri_escape(join '', @_) }); } diff --git a/t/14-meta-helpers.t b/t/14-meta-helpers.t index 2b19e95e..e907f351 100644 --- a/t/14-meta-helpers.t +++ b/t/14-meta-helpers.t @@ -16,7 +16,7 @@ subtest 'html_enc' => sub { is($res, '<', 'single input'); $res = DDGTest::Goodie::MetaOnly::html_enc('>', '<'); - is($res, '>', 'multiple input gets first element'); + is($res, '><', 'multiple input gets concatenated elements'); }; subtest 'array output' => sub { @@ -39,7 +39,7 @@ subtest 'uri_esc' => sub { is($res, '%3C', 'single input'); $res = DDGTest::Goodie::MetaOnly::uri_esc('>', '<'); - is($res, '%3E', 'multiple input gets first element'); + is($res, '%3E%3C', 'multiple input gets concatenated elements'); }; subtest 'array output' => sub {