Merge pull request #570 from duckduckgo/jag/encode

Lowercase/Uppercase: Encode the query before injecting to HTML.
master
Rob Emery 2014-08-01 20:06:01 +01:00
commit 13f6af99e8
2 changed files with 16 additions and 3 deletions

View File

@ -1,6 +1,8 @@
package DDG::Goodie::Lowercase;
use DDG::Goodie;
use HTML::Entities;
# ABSTRACT: Convert a string into lowercase.
name "Lowercase";
description "Convert a string into lowercase.";
@ -25,7 +27,12 @@ sub append_css {
handle remainder => sub {
return unless $_;
my $lower = lc $_;
my $text = "$lower";
my $text = $lower;
# Encode the variable before putting it in HTML.
# There's no need to encode the $text variable because that gets encoded internally.
$lower = encode_entities($lower);
my $html = qq(<div class="zci--lowercase"><span class="text--primary">$lower</span></div>);
$html = append_css($html);

View File

@ -1,7 +1,8 @@
package DDG::Goodie::Uppercase;
use DDG::Goodie;
use HTML::Entities;
triggers startend => 'uppercase', 'upper case', 'allcaps', 'all caps', 'strtoupper', 'toupper';
# leaving out 'uc' because of queries like "UC Berkley", etc
@ -29,7 +30,12 @@ sub append_css {
handle remainder => sub {
return unless $_;
my $upper = uc $_;
my $text = "$upper";
my $text = $upper;
# Encode the variable before putting it in HTML.
# There's no need to encode the $text variable because that gets encoded internally.
$upper = encode_entities($upper);
my $html = qq(<div class="zci--uppercase"><span class="text--primary">$upper</span></div>);
$html = append_css($html);