OSDN Git Service
(root)
/
newslash
/
newslash.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
9052e81
)
Model::Util: add escape_plaintext method
author
hylom
<hylom@users.sourceforge.jp>
Mon, 7 Nov 2016 15:21:22 +0000
(
00:21
+0900)
committer
hylom
<hylom@users.sourceforge.jp>
Mon, 7 Nov 2016 15:21:22 +0000
(
00:21
+0900)
src/newslash_web/lib/Newslash/Model/Util.pm
patch
|
blob
|
history
diff --git
a/src/newslash_web/lib/Newslash/Model/Util.pm
b/src/newslash_web/lib/Newslash/Model/Util.pm
index
d9a5abe
..
8227012
100644
(file)
--- a/
src/newslash_web/lib/Newslash/Model/Util.pm
+++ b/
src/newslash_web/lib/Newslash/Model/Util.pm
@@
-83,4
+83,38
@@
sub escape_html {
return EscapeHTML::escape($allowed, $html);
}
+
+=head2 escape_plaintext($text)
+
+escape HTML
+
+=over 4
+
+=item Parameters
+
+=over 4
+
+=item $text
+
+input plain text
+
+=back
+
+=item Return value
+
+escaped text
+
+=back
+
+=cut
+
+sub escape_plaintext {
+ my ($self, $text) = @_;
+
+ my $t = $text->replace(qr/&(?!|lt;|gt;)/, '&');
+ $t = $t->replace(qr/</, '<');
+ $t = $t->replace(qr/>/, '>');
+ return $t;
+}
+
1;