Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Commit

Permalink
Fix for strings with extra newlines/carriage returns
Browse files Browse the repository at this point in the history
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
majuscule committed Mar 9, 2013
1 parent e8c710b commit 76a5bd2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/App/DuckPAN/Web.pm
Expand Up @@ -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);
Expand Down

0 comments on commit 76a5bd2

Please sign in to comment.