Merge pull request #15 from zaeleus/html_escape
Escape document when using the txt extension
Esse commit está contido em:
+10
-1
@@ -4,6 +4,15 @@ var haste_document = function() {
|
|||||||
this.locked = false;
|
this.locked = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Escapes HTML tag characters
|
||||||
|
haste_document.prototype.htmlEscape = function(s) {
|
||||||
|
return s
|
||||||
|
.replace(/&/g, '&')
|
||||||
|
.replace(/>/g, '>')
|
||||||
|
.replace(/</g, '<')
|
||||||
|
.replace(/"/g, '"');
|
||||||
|
};
|
||||||
|
|
||||||
// Get this document from the server and lock it here
|
// Get this document from the server and lock it here
|
||||||
haste_document.prototype.load = function(key, callback, lang) {
|
haste_document.prototype.load = function(key, callback, lang) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
@@ -17,7 +26,7 @@ haste_document.prototype.load = function(key, callback, lang) {
|
|||||||
try {
|
try {
|
||||||
var high;
|
var high;
|
||||||
if (lang === 'txt') {
|
if (lang === 'txt') {
|
||||||
high = { value: res.data };
|
high = { value: _this.htmlEscape(res.data) };
|
||||||
}
|
}
|
||||||
else if (lang) {
|
else if (lang) {
|
||||||
high = hljs.highlight(lang, res.data);
|
high = hljs.highlight(lang, res.data);
|
||||||
|
|||||||
Externo
+1
-1
Diff do arquivo suprimido porque uma ou mais linhas são muito longas
Referência em uma Nova Issue
Bloquear um usuário