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:
parent
2e5e4d22d1
commit
28bc8d3c7b
@ -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 };
|
||||
}
|
||||
|
||||
@ -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";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user