Browse files

Fix for strings with extra newlines/carriage returns

The \n escaping is working fine, but for HTML output that still has
weird returns, Javascript will take that as a newline and throw an
"Unterminated string literal" error in the browser-side. Removing \R
after the \n have been escaped solves the issue.

Thank you to bureado <https://github.com/bureado>, who authored this
change and commit.
  • Loading branch information...
1 parent e8c710b commit 76a5bd2f0216a5a0e03317ac3d174b98d6b3b100 @majuscule majuscule committed Mar 9, 2013
Showing with 1 addition and 1 deletion.
  1. +1 −1 lib/App/DuckPAN/Web.pm
View
2 lib/App/DuckPAN/Web.pm
@@ -113,7 +113,7 @@ sub request {
elsif ($rewrite->wrap_string_callback && $rewrite->callback) {
$body =~ s/"/\\"/g;
$body =~ s/\n/\\n/g;
- $body =~ s/\r//g;
+ $body =~ s/\R//g;
$body = $rewrite->callback.'("'.$body.'");';
}
$response->code($res->code);

0 comments on commit 76a5bd2

Please sign in to comment.