2amigos / yii2-ckeditor-widget

CKEditor WYSIWYG widget for Yii2.
https://2amigos.us/open-source/ckeditor-widget
Other
172 stars 112 forks source link

registerCsrfImageUploadHandler() not registered / called if filebrowserImageUploadUrl is defined #76

Closed techie42 closed 7 years ago

techie42 commented 8 years ago

In CKEditor.php, if we define filebrowserImageUploadUrl (instead of filebrowserUploadUrl), then the CSRF is never added to the upload data.

In the CKEditor docs, filebrowserUploadUrl defines a generic upload routine and filebrowserImageUploadUrl defines a specific image upload routine.

I would suggest the code is modified as follows (around line 68 of CKEditor.php):

Original: if (isset($this->clientOptions['filebrowserUploadUrl'])) { $js[] = "dosamigos.ckEditorWidget.registerCsrfImageUploadHandler();"; }

Revision: if (isset($this->clientOptions['filebrowserUploadUrl']) || isset($this->clientOptions['filebrowserImageUploadUrl'])) { $js[] = "dosamigos.ckEditorWidget.registerCsrfImageUploadHandler();"; } This solves the issue and specific image uploads occur normally.

Also, CKEditorInline.php would also need to be modified accordingly around line 90, replacing the same code shown above with the revision.

tonydspaniard commented 7 years ago

@techie42 do you have time for a quick PR? I'll review it whenever i have time. Thanks

techie42 commented 7 years ago

Sorry it's taken so long ... but finally done :) Thanks for your patience.