diff --git a/lib/DDG/Goodie/Anagram.pm b/lib/DDG/Goodie/Anagram.pm index f856abd38..96d779b10 100644 --- a/lib/DDG/Goodie/Anagram.pm +++ b/lib/DDG/Goodie/Anagram.pm @@ -3,7 +3,6 @@ package DDG::Goodie::Anagram; use DDG::Goodie; use List::Util 'shuffle'; -use HTML::Entities qw(encode_entities); triggers start => "anagram", "anagrams"; @@ -122,15 +121,15 @@ handle remainder => sub { my @chars = shuffle split (//, $word); $w = join '', @chars; } while ($w eq $word); - return $word, html => html_output ('Sorry, we found no anagrams for "'.encode_entities ($word).'". We scrambled it for you:', $w); + return $word, html => html_output('Sorry, we found no anagrams for "'.html_enc($word).'". We scrambled it for you:', $w); } my $response = join ', ', @output; - my $output_str = 'Anagrams of '.encode_entities ($word).'"'; + my $output_str = 'Anagrams of '.html_enc($word).'"'; unless ($full_word) { $output_str .= " of length $len"; } - return $response, html => html_output ($output_str, $response); + return $response, html => html_output($output_str, $response); }; 1; diff --git a/lib/DDG/Goodie/BashPrimaryExpressions.pm b/lib/DDG/Goodie/BashPrimaryExpressions.pm index 2ab449e21..3a539733d 100644 --- a/lib/DDG/Goodie/BashPrimaryExpressions.pm +++ b/lib/DDG/Goodie/BashPrimaryExpressions.pm @@ -6,8 +6,6 @@ use warnings; use DDG::Goodie; -use HTML::Entities; - triggers startend => 'bash if', 'bash'; primary_example_queries 'bash [ -z hello ]'; secondary_example_queries 'bash if [[ "abc" -lt "cba" ]]'; @@ -87,11 +85,11 @@ handle remainder => sub { my $text_output = $if_description{$op}; $text_output =~ s/^true/false/ if $not; - my $html_output = encode_entities($text_output); - my $html_right_arg = encode_entities($right_arg); + my $html_output = html_enc($text_output); + my $html_right_arg = html_enc($right_arg); if ($left_arg) { - my $html_left_arg = encode_entities($left_arg); + my $html_left_arg = html_enc($left_arg); $text_output =~ s/ARG1/$left_arg/g; $html_output =~ s/ARG1/
$html_left_arg<\/pre>/g;	
 	}
@@ -99,8 +97,8 @@ handle remainder => sub {
 	$text_output =~ s/ARG2/$right_arg/g;
 	$html_output =~ s/ARG2/
$html_right_arg<\/pre>/g;
 	
-	my $intro = "The Bash expression 
" . encode_entities($_) . "
results to"; - return "$intro $text_output.", html => append_css("$intro $html_output."), heading => encode_entities($_) . " (Bash)"; + my $intro = "The Bash expression
" . html_enc($_) . "
results to"; + return "$intro $text_output.", html => append_css("$intro $html_output."), heading => html_enc($_) . " (Bash)"; }; 1; diff --git a/lib/DDG/Goodie/Conversions.pm b/lib/DDG/Goodie/Conversions.pm index a94f7b887..46000bcb5 100755 --- a/lib/DDG/Goodie/Conversions.pm +++ b/lib/DDG/Goodie/Conversions.pm @@ -4,7 +4,6 @@ package DDG::Goodie::Conversions; use DDG::Goodie; with 'DDG::GoodieRole::NumberStyler'; -use HTML::Entities; use Math::Round qw/nearest/; use bignum; use Convert::Pluggable; @@ -68,8 +67,8 @@ sub append_css { sub wrap_html { my ($factor, $result, $styler) = @_; - my $from = $styler->with_html($factor) . " " . encode_entities($result->{'from_unit'}) . ""; - my $to = $styler->with_html($result->{'result'}) . " " . encode_entities($result->{'to_unit'}) . ""; + my $from = $styler->with_html($factor) . " " . html_enc($result->{'from_unit'}) . ""; + my $to = $styler->with_html($result->{'result'}) . " " . html_enc($result->{'to_unit'}) . ""; return append_css("
$from = $to
"); } @@ -171,4 +170,4 @@ handle query_lc => sub { return $output, html => wrap_html($factor, $result, $styler); }; -1; \ No newline at end of file +1; diff --git a/lib/DDG/Goodie/ConvertLatLon.pm b/lib/DDG/Goodie/ConvertLatLon.pm index ea46f59b6..c752326d8 100644 --- a/lib/DDG/Goodie/ConvertLatLon.pm +++ b/lib/DDG/Goodie/ConvertLatLon.pm @@ -4,7 +4,6 @@ package DDG::Goodie::ConvertLatLon; use DDG::Goodie; use utf8; use Geo::Coordinates::DecimalDegrees; -use HTML::Entities; use Math::SigFigs qw(:all); use Math::Round; @@ -280,8 +279,8 @@ sub wrap_html { my @results = @{$_[1]}; my $toFormat = $_[2]; - my $queries = join wrap_secondary(', '), map { encode_entities($_) } @queries; - my $results = join wrap_secondary(', '), map { encode_entities($_) } @results; + my $queries = join wrap_secondary(', '), html_enc(@queries); + my $results = join wrap_secondary(', '), html_enc(@results); my $html = "
" . $queries . wrap_secondary(' in ' . $toFormat . ': ') . $results . "
"; return append_css($html); diff --git a/lib/DDG/Goodie/HTMLEntitiesEncode.pm b/lib/DDG/Goodie/HTMLEntitiesEncode.pm index e46bdc71b..74e4d6bda 100644 --- a/lib/DDG/Goodie/HTMLEntitiesEncode.pm +++ b/lib/DDG/Goodie/HTMLEntitiesEncode.pm @@ -1,7 +1,6 @@ package DDG::Goodie::HTMLEntitiesEncode; # ABSTRACT: Displays the HTML entity code for the query name. -use HTML::Entities qw(encode_entities); use DDG::Goodie; use strict; use warnings; @@ -301,16 +300,16 @@ handle remainder => sub { } # Query maybe a single typed-in character to encode - # No hits above if we got this far, use encode_entities() of HTML::Entities + # No hits above if we got this far, use html_enc() if ( (/^(?:")(?.)(?:")\s*\??$/) # a (captured) single character within double quotes || (/^(?:'')(?.)(?:'')\s*\??$/) # or within single quotes || (/^(?.)\s*\??$/)) { # or stand-alone - my $entity = encode_entities($+{char}); - if ($entity eq $+{char}) { # encode_entities() was unsuccessful and returned the input itself + my $entity = html_enc($+{char}); + if ($entity eq $+{char}) { # html_enc() was unsuccessful and returned the input itself $entity = ord($+{char}); # get the decimal $entity = '#' . $entity; # dress it up like a decimal } - # Remove '&' and ';' from the output of encode_entities(), these will be added in html + # Remove '&' and ';' from the output of html_enc(), these will be added in html $entity =~ s/^&//g; $entity =~ s/;$//g; # Make final answer diff --git a/lib/DDG/Goodie/IDN.pm b/lib/DDG/Goodie/IDN.pm index be19234f4..f6e3f4088 100644 --- a/lib/DDG/Goodie/IDN.pm +++ b/lib/DDG/Goodie/IDN.pm @@ -3,7 +3,6 @@ package DDG::Goodie::IDN; use DDG::Goodie; use Net::IDN::Encode ':all'; -use HTML::Entities; use utf8; primary_example_queries 'idn exämple.com'; @@ -31,10 +30,10 @@ handle query_lc => sub { $idn = 'internationalized domain: ' if $1 eq 'internationalize domain'; return unless m/\.(ac|ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|asia|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cat|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cu|cv|cw|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|info|int|io|iq|ir|is|it|je|jm|jo|jobs|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|local|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mil|mk|ml|mm|mn|mo|mobi|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sx|sy|sz|tc|td|tel|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|travel|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|xxx|ye|yt|za|zm|zw)$/i; if(/^xn--/) { - return 'Decoded ' . $idn . encode_entities(domain_to_unicode($_)); + return 'Decoded ' . $idn . html_enc(domain_to_unicode($_)); } else { - return 'Encoded ' . $idn . encode_entities(domain_to_ascii($_)); + return 'Encoded ' . $idn . html_enc(domain_to_ascii($_)); } return; }; diff --git a/lib/DDG/Goodie/Lowercase.pm b/lib/DDG/Goodie/Lowercase.pm index 4a9636c7f..2bd7fe357 100644 --- a/lib/DDG/Goodie/Lowercase.pm +++ b/lib/DDG/Goodie/Lowercase.pm @@ -3,8 +3,6 @@ package DDG::Goodie::Lowercase; use DDG::Goodie; -use HTML::Entities; - name "Lowercase"; description "Convert a string into lowercase."; primary_example_queries "lowercase GitHub"; @@ -32,7 +30,7 @@ handle remainder => sub { # 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); + $lower = html_enc($lower); my $html = qq(
$lower
); $html = append_css($html); diff --git a/lib/DDG/Goodie/MD5.pm b/lib/DDG/Goodie/MD5.pm index cf7e5bc08..6bf9f0a29 100644 --- a/lib/DDG/Goodie/MD5.pm +++ b/lib/DDG/Goodie/MD5.pm @@ -4,7 +4,6 @@ package DDG::Goodie::MD5; use DDG::Goodie; use Digest::MD5 qw(md5_base64 md5_hex); use Encode qw(encode); -use HTML::Entities qw(encode_entities); zci answer_type => 'md5'; zci is_cached => 1; @@ -26,7 +25,7 @@ sub html_output { my ($str, $md5) = @_; # prevent XSS - $str = encode_entities($str); + $str = html_enc($str); return "" ."
" diff --git a/lib/DDG/Goodie/RegexCheatSheet.pm b/lib/DDG/Goodie/RegexCheatSheet.pm index 9165a7e2c..07e72d2a0 100644 --- a/lib/DDG/Goodie/RegexCheatSheet.pm +++ b/lib/DDG/Goodie/RegexCheatSheet.pm @@ -4,7 +4,6 @@ package DDG::Goodie::RegexCheatSheet; use strict; use warnings; -use HTML::Entities; use DDG::Goodie; zci answer_type => "regex_cheat"; @@ -216,7 +215,7 @@ handle remainder => sub { # Let the user provide a number for the {n} pattern, e.g., {5} would say "Exactly 5 occurrences". elsif ($_ =~ /^\{([0-9]+)\}$/) { return answer => "$_ - Exactly $1 occurrences", - html => "" . encode_entities($_) . " - Exactly " . encode_entities($_) . " occurrences", + html => "" . html_enc($_) . " - Exactly " . html_enc($_) . " occurrences", heading => $heading; } # Let the user provide numbers for {n,} and {n,m}, e.g., {4,} would say "4 or more occurrences". @@ -224,18 +223,18 @@ handle remainder => sub { if ($2) { return unless ($1 < $2); return answer => "$_ - Between $1 and $2 occurrences", - html => "" . encode_entities($_) . " - Between $1 and $2 occurrences", + html => "" . html_enc($_) . " - Between $1 and $2 occurrences", heading => $heading; } return answer => "$_ - $1 or more", - html => "" . encode_entities($_) . " - $1 or more occurrences", + html => "" . html_enc($_) . " - $1 or more occurrences", heading => $heading; } # Check our map if it's in our list of regex patterns. return unless $syntax_map{$syntax_key}; my $text_output = "$_ - $syntax_map{$syntax_key}"; - my $html_output = "" . encode_entities($_) . " - " . encode_entities($syntax_map{$syntax_key}); + my $html_output = "" . html_enc($_) . " - " . html_enc($syntax_map{$syntax_key}); return answer => $text_output, html => $html_output, heading => $heading; } @@ -250,9 +249,9 @@ handle remainder => sub { sub add_table_data { my ($text, $is_code) = @_; if($is_code) { - return "" . encode_entities($text) . ""; + return "" . html_enc($text) . ""; } - return "" . encode_entities($text) . ""; + return "" . html_enc($text) . ""; } for(my $column = 0; $column < scalar(@category_column); ++$column) { diff --git a/lib/DDG/Goodie/Uppercase.pm b/lib/DDG/Goodie/Uppercase.pm index 1ab1a2267..cb48dd7f0 100644 --- a/lib/DDG/Goodie/Uppercase.pm +++ b/lib/DDG/Goodie/Uppercase.pm @@ -3,8 +3,6 @@ package DDG::Goodie::Uppercase; use DDG::Goodie; -use HTML::Entities; - triggers start => 'uppercase', 'upper case', 'allcaps', 'all caps', 'strtoupper', 'toupper'; # leaving out 'uc' because of queries like "UC Berkley", etc # 2014-08-10: triggers to "start"-only to make it act more like a "command" @@ -38,7 +36,7 @@ handle remainder => sub { # 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); + $upper = html_enc($upper); my $html = qq(
$upper
); $html = append_css($html);