From f0c12d38845a46085e96b101b47c43116da039cf Mon Sep 17 00:00:00 2001 From: John McLear Date: Mon, 6 Oct 2014 14:18:54 +0100 Subject: [PATCH 1/2] escape useragent before displaying --- src/static/js/pad_utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/static/js/pad_utils.js b/src/static/js/pad_utils.js index bab6aa432..bcfa95cc6 100644 --- a/src/static/js/pad_utils.js +++ b/src/static/js/pad_utils.js @@ -520,7 +520,7 @@ function setupGlobalExceptionHandler() { $("#editorloadingbox").css("padding", "10px"); $("#editorloadingbox").css("padding-top", "45px"); $("#editorloadingbox").html("
An error occured
The error was reported with the following id: '" + errorId + "'

Please press and hold Ctrl and press F5 to reload this page, if the problem persists please send this error message to your webmaster:
'" - + "ErrorId: " + errorId + "
URL: " + window.location.href + "
UserAgent: " + navigator.userAgent + "
" + msg + " in " + url + " at line " + linenumber + "'
"); + + "ErrorId: " + errorId + "
URL: " + window.location.href + "
UserAgent: " + padutils.escapeHtml(navigator.userAgent) + "
" + msg + " in " + url + " at line " + linenumber + "'"); } //send javascript errors to the server From 0962f65c085bc11c4441d5e11049ba68c5fdea11 Mon Sep 17 00:00:00 2001 From: John McLear Date: Mon, 6 Oct 2014 14:23:13 +0100 Subject: [PATCH 2/2] I prefer this.. --- src/static/js/pad_utils.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/static/js/pad_utils.js b/src/static/js/pad_utils.js index bcfa95cc6..c2ff6fd0e 100644 --- a/src/static/js/pad_utils.js +++ b/src/static/js/pad_utils.js @@ -515,12 +515,13 @@ function setupGlobalExceptionHandler() { globalExceptionHandler = function test (msg, url, linenumber) { var errorId = randomString(20); + var userAgent = padutils.escapeHtml(navigator.userAgent); if ($("#editorloadingbox").attr("display") != "none"){ //show javascript errors to the user $("#editorloadingbox").css("padding", "10px"); $("#editorloadingbox").css("padding-top", "45px"); $("#editorloadingbox").html("
An error occured
The error was reported with the following id: '" + errorId + "'

Please press and hold Ctrl and press F5 to reload this page, if the problem persists please send this error message to your webmaster:
'" - + "ErrorId: " + errorId + "
URL: " + window.location.href + "
UserAgent: " + padutils.escapeHtml(navigator.userAgent) + "
" + msg + " in " + url + " at line " + linenumber + "'
"); + + "ErrorId: " + errorId + "
URL: " + window.location.href + "
UserAgent: " + userAgent + "
" + msg + " in " + url + " at line " + linenumber + "'"); } //send javascript errors to the server