-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
Preconditions
- 2.2.5
Steps to reproduce
-
Open WYSIWYG editor for a product select option to insert image and upload file which base64 encoded filename would use any of special allowed characters (like =), for example: regular_png_.png
-
Select uploaded image and insert it. In upload dialog in Image URL field you will see URL like:
http://magento2.local/admin/cms/wysiwyg/directive/___directive/e3ttZWRpYSB1cmw9Ind5c2l3eWcvcmVndWxhcl9wbmdfLnBuZyJ9fQ%2C%2C/key/3f5dc8b87aa830fa268477f1c1f8ac2e4ac2e435234c4b8d6affec1201033b3a/
Notice: "%2C%2C" part of URL.
-
Image will be correctly displayed in WYSIWYG editor.
-
Click "Show/Hide editor" to check result
Expected result
<img src="{{media url="wysiwyg/regular_png_.png"}}" />
Actual result
<img src="http://magento2.local/admin/cms/wysiwyg/directive/___directive/e3ttZWRpYSB1cmw9Ind5c2l3eWcvcmVndWxhcl9wbmdfLnBuZyJ9fQ%2C%2C/key/3f5dc8b87aa830fa268477f1c1f8ac2e4ac2e435234c4b8d6affec1201033b3a/" width="472" height="472" />
I was trying to track that bug down by myself. It all comes to the fact that directive url generated by "onInsert" action uses standard urlencoder, which uses standard PHP "rawurlencode" function.
That function turns base64 encoded (= is turned into "," after encoding)
"e3ttZWRpYSB1cmw9Ind5c2l3eWcvcmVndWxhcl9wbmdfLnBuZyJ9fQ,,"
into
"e3ttZWRpYSB1cmw9Ind5c2l3eWcvcmVndWxhcl9wbmdfLnBuZyJ9fQ%2C%2C"
WYSIWYG editor on the other hand expects decoded URL like: "e3ttZWRpYSB1cmw9Ind5c2l3eWcvcmVndWxhcl9wbmdfLnBuZyJ9fQ,,"
var url = this.makeDirectiveUrl('%directive%').replace(/([$^.?*!+:=()\[\]{}|\\])/g, '\\$1'),
reg = new RegExp(url.replace('%directive%', '([a-zA-Z0-9,_-]+)'));
So the rexexp part does not find URLS containing "%" at all.