Opened 14 years ago
Closed 10 years ago
#7927 closed Bug (fixed)
bbcode and js event problem
Reported by: | zleaf | Owned by: | |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | General | Version: | 3.6 |
Keywords: | Cc: |
Description (last modified by )
for example: after paste a image in ckeditor in bbcode mode, (the image is like :
<img src="http://cksource.com/forums/images/smilies/icon_e_biggrin.gif" onclick="alert('abc')">
), then click the View Source button, error occur...
here's my way to fix this problem, hoping the official way
function purge(d){ var a=d.attributes,i,l,n; if(a){ l=a.length; for(i=0;i<l;i+=1){ n=a[i].name; if(typeof d[n]==='function'){ d[n]=null; } } } a=d.childNodes; if(a){ l=a.length; for(i=0;i<l;i+=1){ purge(d.childNodes[i]); } } } editor.on( 'insertHtml', function(data){ var t=document.createElement('div'); document.body.appendChild(t); t.innerHTML = data.data; purge(t); data.data = t.innerHTML; document.body.removeChild(t); });
Change History (6)
comment:1 Changed 14 years ago by
Description: | modified (diff) |
---|
comment:2 follow-up: 4 Changed 14 years ago by
Status: | new → pending |
---|
comment:3 Changed 14 years ago by
Keywords: | bbcode removed |
---|
comment:4 Changed 14 years ago by
Replying to j.swiderski:
I'm a little confused here because I could not reproduce the issue (nor win nor linux). I have tried to paste the following code and switch mode but sisn't get any errors.
Could you:
- Tell me what Operating System are you using.
- Tell me what browser are you using
- Provide me with a step by step Test Case so that I could easily reproduce the issue
Waiting for your comments.
Sorry I'm so late to reply. I checked my code and I found that I didn't describe the problem correctly, here're my steps in php:
1 the php code is like:
$CKEditor = new CKEditor(); .... ... .. $CKEditor->config['html'] = $Content; .... ... .. $CKEditor->addGlobalEventHandler('instanceReady', "function( ev ){ var editor=ev.editor; editor.insertHtml(editor.config.html); }"); .... ... .. $CKEditor->editor("Content","");
2 $Content is like
<IMG onclick="if(this.width>=100)alert('aaa');" border=0 src="http://dev.ckeditor.com/chrome/site/logo-ckeditor-dev.png">
3 When switching mode we'll see the js error( not just in bbcode mode), I thought it's because of the '>' in '>=100'.
My browser is IE7 in WinXP
comment:5 Changed 14 years ago by
Status: | pending → confirmed |
---|
First of all there should be slashes used with 'aaa'-> \'aaa\'
<IMG onclick="if(this.width>=100)alert(\'aaa\');" border=0 src="http://dev.ckeditor.com/chrome/site/logo-ckeditor-dev.png"/>
Second I don't see problems in any sample except bbcode.
TC:
- Paste the following code to your config.js
CKEDITOR.on('instanceReady', function( ev ){ CKEDITOR.config['html'] = '<IMG onclick="if(this.width>=100)alert(\'aaa\');" border=0 src="http://dev.ckeditor.com/chrome/site/logo-ckeditor-dev.png"/>'; var editor=ev.editor; editor.insertHtml(editor.config.html); });
- Open bbcode sample
- Switch to source mode
Result: JS error occurs
Message: „text is undefined”
Line: 167
URI: /_source/plugins/entities/plugin.js
The cause of the problem is -> onclick="if(this.width>=100)alert(\'aaa\');"
Reproducible in all browsers from CKEditor 3.6 rev [6904]
comment:6 Changed 10 years ago by
Resolution: | → fixed |
---|---|
Status: | confirmed → closed |
This issue seems to be fixed in CKEditor 4.x.
I'm a little confused here because I could not reproduce the issue (nor win nor linux). I have tried to paste the following code and switch mode but sisn't get any errors.
Could you:
Waiting for your comments.