summaryrefslogtreecommitdiff
path: root/public/js/index.js
diff options
context:
space:
mode:
authorWu Cheng-Han2017-01-02 11:05:05 +0800
committerWu Cheng-Han2017-01-02 11:05:05 +0800
commitd9e19b602968551fcda4ee806d767a04f6a11490 (patch)
tree788b3f708545b2875f115c5716b7849c1cc9ad03 /public/js/index.js
parentc3a96ff112c8f7ea31af97fbc3319e782f4490e2 (diff)
Update to remove null byte before saving to DB and remove null byte on changes
Diffstat (limited to 'public/js/index.js')
-rw-r--r--public/js/index.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/public/js/index.js b/public/js/index.js
index 328b67fe..e62d1dcb 100644
--- a/public/js/index.js
+++ b/public/js/index.js
@@ -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');
}