mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-18 00:54:43 -04:00
Update to remove null byte before saving to DB and remove null byte on changes
This commit is contained in:
parent
c3a96ff112
commit
d9e19b6029
4 changed files with 42 additions and 7 deletions
|
@ -3207,6 +3207,12 @@ function buildCursor(user) {
|
|||
}
|
||||
|
||||
//editor actions
|
||||
function removeNullByte(cm, change) {
|
||||
var str = change.text.join("\n");
|
||||
if (/\u0000/g.test(str) && change.update) {
|
||||
change.update(change.from, change.to, str.replace(/\u0000/g, "").split("\n"));
|
||||
}
|
||||
}
|
||||
function enforceMaxLength(cm, change) {
|
||||
var maxLength = cm.getOption("maxLength");
|
||||
if (maxLength && change.update) {
|
||||
|
@ -3228,6 +3234,7 @@ var ignoreEmitEvents = ['setValue', 'ignoreHistory'];
|
|||
editor.on('beforeChange', function (cm, change) {
|
||||
if (debug)
|
||||
console.debug(change);
|
||||
removeNullByte(cm, change);
|
||||
if (enforceMaxLength(cm, change)) {
|
||||
$('.limit-modal').modal('show');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue