Signed-off-by: Francois Gouget fgouget@codeweavers.com --- This is not related to the previous patch except that the code is in the same area. --- testbot/lib/ObjectModel/CGI/Page.pm | 20 ++++++++++++++++++++ testbot/lib/WineTestBot/CGI/PageBase.pm | 5 +---- 2 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/testbot/lib/ObjectModel/CGI/Page.pm b/testbot/lib/ObjectModel/CGI/Page.pm index 6197e4e38..f7e3c93b8 100644 --- a/testbot/lib/ObjectModel/CGI/Page.pm +++ b/testbot/lib/ObjectModel/CGI/Page.pm @@ -144,6 +144,26 @@ sub escapeHTML($$) =pod =over 12
+=head1 C<jsQuote()> + +Quotes a string for JavaScript code. + +=back +=cut + +sub jsQuote($$) +{ + my ($self, $String) = @_; + + $String =~ s~\~\\~g; + $String =~ s~"~\"~g; + $String =~ s~\n~\n~g; + return ""$String""; +} + +=pod +=over 12 + =head1 C<SetRefreshInterval()>
Sets the page refresh interval in seconds. diff --git a/testbot/lib/WineTestBot/CGI/PageBase.pm b/testbot/lib/WineTestBot/CGI/PageBase.pm index 5ce070189..d5fcc478a 100644 --- a/testbot/lib/WineTestBot/CGI/PageBase.pm +++ b/testbot/lib/WineTestBot/CGI/PageBase.pm @@ -323,10 +323,7 @@ sub GenerateErrorPopup($$) { print "<script type='text/javascript'>\n"; print "<!--\n"; - $ErrMessage =~ s~\~\\~g; - $ErrMessage =~ s~"~\"~g; - $ErrMessage =~ s~\n~\n~g; - print "function ShowError() { alert("$ErrMessage"); }\n"; + print "function ShowError() { alert(", $Page->jsQuote($ErrMessage), "); }\n"; my $ErrField = $Page->GetErrField(); if ($ErrField) {