Conversions: Encode HTML output.

master
jagtalon 2014-06-04 21:16:36 +00:00
parent aabe2f2e0a
commit d3c5a5bb4a
1 changed files with 4 additions and 2 deletions

View File

@ -2,6 +2,8 @@ package DDG::Goodie::Conversions;
# ABSTRACT: convert between various units of measurement # ABSTRACT: convert between various units of measurement
use DDG::Goodie; use DDG::Goodie;
use HTML::Entities;
use Math::Round qw/nearest/; use Math::Round qw/nearest/;
use Scalar::Util qw/looks_like_number/; use Scalar::Util qw/looks_like_number/;
use bignum; use bignum;
@ -65,8 +67,8 @@ sub append_css {
sub wrap_html { sub wrap_html {
my ($factor, $result) = @_; my ($factor, $result) = @_;
my $from = "$factor <span class='unit'>$result->{'from_unit'}</span>"; my $from = encode_entities($factor) . " <span class='unit'>" . encode_entities($result->{'from_unit'}) . "</span>";
my $to = "$result->{'result'} <span class='unit'>$result->{'to_unit'}</span>"; my $to = encode_entities($result->{'result'}) . " <span class='unit'>" . encode_entities($result->{'to_unit'}) . "</span>";
return append_css("<div class='zci--conversions'>$from = $to</div>"); return append_css("<div class='zci--conversions'>$from = $to</div>");
} }