Merge pull request #146 from tophf/fixes
Editor: escape html in CSSLint report, limit message length
This commit is contained in:
commit
2e8ad06703
10
edit.js
10
edit.js
|
@ -859,13 +859,17 @@ function updateLintReport(cm, delay) {
|
|||
delete oldMarkers[pos];
|
||||
}
|
||||
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 + "'>" +
|
||||
"<td role='severity' class='CodeMirror-lint-marker-" + info.severity + "'>" +
|
||||
info.severity + "</td>" +
|
||||
"<td role='line'>" + (info.from.line+1) + "</td>" +
|
||||
"<td role='sep'>:</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>";
|
||||
cm.state.lint.markedLast = newMarkers;
|
||||
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) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user