Bug 270302 - Escape CSV profiler output.

JavaScript Debugger only.
r=rginda


git-svn-id: svn://10.0.0.236/trunk@214009 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
silver%warwickcompsoc.co.uk 2006-10-23 18:40:33 +00:00
parent 2e5e4d22d1
commit 28bc8d3c7b
2 changed files with 20 additions and 2 deletions

View File

@ -61,9 +61,11 @@ function ProfileReport (reportTemplate, file, rangeList, scriptInstanceList)
this.scriptInstanceList = scriptInstanceList;
this.key = "total";
// Escape bad characters for HTML and XML profiles.
// Escape bad characters for HTML, XML and CSV profiles.
if (/\.(html|xml)\.tpl$/.test(this.reportTemplate.__url__))
this.escape = safeHTML;
else if (/\.csv\.tpl$/.test(this.reportTemplate.__url__))
this.escape = safeCSV;
else
this.escape = function _nop_escape(s) { return s };
}

View File

@ -239,10 +239,26 @@ function safeHTML(str)
return "?";
};
return String(str).replace(/[<>&"']/g, replaceChars);
}
function safeCSV(str)
{
function replaceChars(ch)
{
switch (ch)
{
case '"':
return '""';
}
return "?";
}
return '"' + String(str).replace(/"/g, replaceChars) + '"';
}
function alert(msg, parent, title)
{
var PROMPT_CTRID = "@mozilla.org/embedcomp/prompt-service;1";