Skip to content

Commit

Permalink
implemented CKEditor paste event capture to prevent images over 1M fr…
Browse files Browse the repository at this point in the history
…om being pasted into editor
  • Loading branch information
turnermm committed Nov 22, 2018
1 parent e820290 commit f7d3162
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function registerOnLoad($js){
}
}


$ckg_brokenimg = $this->getLang('broken_image');
$default_fb = $this->getConf('default_fb');
if($default_fb == 'none') {
$client = "";
Expand Down Expand Up @@ -472,6 +472,18 @@ function FCKeditor_OnComplete( editorInstance )
editorInstance.on("focus", function(e) {
window.dwfckTextChanged = true;
});
var broken_image ='http://' + location.host + DOKU_BASE + '/lib/plugins/ckgedit/fckeditor/userfiles/blink.jpg?nolink&33x34';
editorInstance.on("paste", function(e) {
var len = e.data.dataValue.length;
var broken_msg = "$ckg_brokenimg " + len;
if(e.data.dataValue.match(/data:image\/\w+;base64/) && len > 100000 ) {
alert(broken_msg + len);
e.data.dataValue = '<img src ='+ broken_image + '/>';
}
});
oDokuWiki_FCKEditorInstance.dwiki_user = "$user_type";
oDokuWiki_FCKEditorInstance.dwiki_client = "$client";
Expand Down
1 change: 1 addition & 0 deletions lang/en/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,4 @@
$lang['js']['on'] ='on';
$lang['js']['off'] ='off';
$lang['broken_image'] = 'Use the imagePaste plugin with the Dokuwiki Mediamanager. Raw data of Ctrl-v images cannot exceed 1M. This image is: ';

0 comments on commit f7d3162

Please sign in to comment.