mirror of https://github.com/mthenw/frontail.git
Test escaping HTML fix #50
parent
3879a6eb79
commit
054eb70c46
|
@ -182,18 +182,9 @@ window.App = (function (window, document) {
|
|||
* @private
|
||||
*/
|
||||
var _escape = function (text) {
|
||||
var entityMap = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
'\'': ''',
|
||||
'/': '/'
|
||||
};
|
||||
|
||||
return String(text).replace(/[&<>"'\/]/g, function (s) {
|
||||
return entityMap[s];
|
||||
});
|
||||
var div = document.createElement('div');
|
||||
div.appendChild(document.createTextNode(text));
|
||||
return div.innerHTML;
|
||||
};
|
||||
|
||||
return {
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
"jscs": "^1.6.2",
|
||||
"jsdom": "^3.1.0",
|
||||
"jshint": "~2.3.0",
|
||||
"mocha": "~2.2.0",
|
||||
"mocha": "~2.3.2",
|
||||
"should": "~3.3.2",
|
||||
"sinon": "~1.7.3",
|
||||
"supertest": "~0.8.1",
|
||||
|
|
|
@ -98,6 +98,13 @@ describe('browser application', function () {
|
|||
);
|
||||
});
|
||||
|
||||
it('should escape HTML', function () {
|
||||
io.emit('line', '<a/>');
|
||||
|
||||
var line = window.document.querySelector('.line');
|
||||
line.innerHTML.should.equal('<p class="inner-line"><a/></p>');
|
||||
});
|
||||
|
||||
function initApp() {
|
||||
window.App.init({
|
||||
socket: io,
|
||||
|
|
Loading…
Reference in New Issue