Editor: escape html in CSSLint report, limit message length
This commit is contained in:
parent
7f0557df57
commit
55c48d62fc
10
edit.js
10
edit.js
|
@ -859,13 +859,17 @@ function updateLintReport(cm, delay) {
|
||||||
delete oldMarkers[pos];
|
delete oldMarkers[pos];
|
||||||
}
|
}
|
||||||
newMarkers[pos] = info.message;
|
newMarkers[pos] = info.message;
|
||||||
|
var message = escapeHtml(info.message.replace(/ at line \d.+$/, ""));
|
||||||
|
if (message.length > 100) {
|
||||||
|
message = message.substr(0, 100) + "...";
|
||||||
|
}
|
||||||
return "<tr class='" + info.severity + "'>" +
|
return "<tr class='" + info.severity + "'>" +
|
||||||
"<td role='severity' class='CodeMirror-lint-marker-" + info.severity + "'>" +
|
"<td role='severity' class='CodeMirror-lint-marker-" + info.severity + "'>" +
|
||||||
info.severity + "</td>" +
|
info.severity + "</td>" +
|
||||||
"<td role='line'>" + (info.from.line+1) + "</td>" +
|
"<td role='line'>" + (info.from.line+1) + "</td>" +
|
||||||
"<td role='sep'>:</td>" +
|
"<td role='sep'>:</td>" +
|
||||||
"<td role='col'>" + (info.from.ch+1) + "</td>" +
|
"<td role='col'>" + (info.from.ch+1) + "</td>" +
|
||||||
"<td role='message'>" + info.message.replace(/ at line \d.+$/, "") + "</td></tr>";
|
"<td role='message'>" + message + "</td></tr>";
|
||||||
}).join("") + "</tbody>";
|
}).join("") + "</tbody>";
|
||||||
cm.state.lint.markedLast = newMarkers;
|
cm.state.lint.markedLast = newMarkers;
|
||||||
fixedOldIssues |= Object.keys(oldMarkers).length > 0;
|
fixedOldIssues |= Object.keys(oldMarkers).length > 0;
|
||||||
|
@ -885,6 +889,10 @@ function updateLintReport(cm, delay) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function escapeHtml(html) {
|
||||||
|
var chars = {"&": "&", "<": "<", ">": ">", '"': '"', "'": ''', "/": '/'};
|
||||||
|
return html.replace(/[&<>"'\/]/g, function(char) { return chars[char] });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderLintReport(blockChanged) {
|
function renderLintReport(blockChanged) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user