Доработки конвертирования из буфера обмена

This commit is contained in:
Book Pauk
2020-02-06 21:04:40 +07:00
parent 8007991e7d
commit a6bdccd4ef
3 changed files with 16 additions and 1 deletions

View File

@@ -70,7 +70,7 @@ class PasteTextPage extends Vue {
}
loadBuffer() {
this.$emit('load-buffer', {buffer: `<cut-title>${this.bookTitle}</cut-title>${this.$refs.textArea.value}`});
this.$emit('load-buffer', {buffer: `<buffer><cut-title>${utils.escapeXml(this.bookTitle)}</cut-title>${this.$refs.textArea.value}</buffer>`});
this.close();
}

View File

@@ -193,4 +193,13 @@ export function parseQuery(str) {
query[first] = [query[first], second];
}
return query;
}
export function escapeXml(str) {
return str.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&apos;')
;
}