From: Moritz Bunkus Date: Tue, 5 Mar 2013 12:14:00 +0000 (+0100) Subject: Presenter: escape_js() zum Escapen von JavaScript X-Git-Tag: release-3.1.0beta1~565 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=8817f25b3b69622f98edfc74393ae8d88f827b7a;p=kivitendo-erp.git Presenter: escape_js() zum Escapen von JavaScript --- diff --git a/SL/Presenter.pm b/SL/Presenter.pm index f328cce9e..36acc73dd 100644 --- a/SL/Presenter.pm +++ b/SL/Presenter.pm @@ -124,6 +124,16 @@ sub escaped_text { return SL::Presenter::EscapedText->new(text => $text, is_escaped => 1); } +sub escape_js { + my ($self, $text) = @_; + + $text =~ s|\\|\\\\|g; + $text =~ s|\"|\\\"|g; + $text =~ s|\n|\\n|g; + + return SL::Presenter::EscapedText->new(text => $text, is_escaped => 1); +} + 1; __END__ @@ -290,6 +300,16 @@ It is safe to call C on an instance of L. This is a no-op (the same instance will be returned). +=item C + +Returns a JavaScript-escaped version of C<$text>. Instead of a string +an instance of the thin proxy-object L is +returned. + +It is safe to call C on an instance of +L. This is a no-op (the same instance will +be returned). + =item C Returns the global instance of L