summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Woodward2010-05-16 14:20:05 -0400
committerJason Woodward2010-05-16 14:20:05 -0400
commit20d510935916577fd3db47cfd43d178203a5fe30 (patch)
tree2f349d6a5b2e7bbf895c0a3091bd185de249ba65
parent6c21bda995df3ebe9baf41fc3bbd8951f6bba866 (diff)
downloadJaos-WebApp-20d510935916577fd3db47cfd43d178203a5fe30.tar.gz
added encode_html and decode_html controller helper methods
-rw-r--r--lib/Jaos/WebApp/Controller.pm28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/Jaos/WebApp/Controller.pm b/lib/Jaos/WebApp/Controller.pm
index cbbc525..15508e5 100644
--- a/lib/Jaos/WebApp/Controller.pm
+++ b/lib/Jaos/WebApp/Controller.pm
@@ -49,6 +49,30 @@ sub redirect_to
$self->{app}->res->redirect($uri);
}
+
+sub encode_html
+{
+ my ($self, $str) = @_;
+ $str =~ s/&/&/g;
+ $str =~ s/>/>/g;
+ $str =~ s/</&lt;/g;
+ $str =~ s/"/&quot;/g;
+ $str =~ s/'/&#39;/g;
+ return $str;
+}
+
+sub decode_html
+{
+ my ($self, $str) = @_;
+ $str =~ s/&amp;/&/g;
+ $str =~ s/&gt;/>/g;
+ $str =~ s/&lt;/</g;
+ $str =~ s/&quot;/"/g;
+ $str =~ s/&#39;/'/g;
+ return $str;
+}
+
+
=head1 NAME
Jaos::WebApp::Controller - Base class for Jaos::WebApp controllers
@@ -111,6 +135,10 @@ Dispatch to the specified render type handler. Each handler is registered with
Redirects to the specified location. url_for is called internally for generating the full path to the mounted location. This is a slight wrapper around L<Plack::Response>->redirect().
+=head2 encode_html
+
+=head2 decode_html
+
=head1 AUTHOR
Jason Woodward <woodwardj@jaos.org>