Closed (outdated)
Project:
TinyMCE
Version:
6.x-1.1-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
27 Dec 2008 at 14:54 UTC
Updated:
14 Jan 2021 at 19:52 UTC
Jump to comment: Most recent
I.m trying to add custom JS code to $init section throught the template.php, for eaxample:
$init['setup'] = 'function(ed){ alert(123); }';
But in HTML code it escapes with quotes like:
setup : "function(ed){ alert(123); }"
While digging into module I found such code in $init preparation:
// Don't wrap the JS init in quotes for boolean values or functions.
if (strtolower($v) != 'true' && strtolower($v) != 'false' && $v[0] != '{') {
$v = '"'. $v .'"';
}
It says that it should filter functions out, but it don't. I think it should be like this:
// Don't wrap the JS init in quotes for boolean values or functions.
if (strtolower($v) != 'true' && strtolower($v) != 'false' && strpos($v, 'function') !== 0) {
$v = '"'. $v .'"';
}
This code checks if function is in right beginning of the string. Also, I've prepared a patch to solve this issue quickly.
Thanks.
| Comment | File | Size | Author |
|---|---|---|---|
| tinymce_init_functions.patch | 601 bytes | neochief |
Comments
Comment #1
nicoloye commented