When bbcode tags aren't terminated it breaks completly the editor
Type of report
Bug
Provide detailed reproduction steps (if any)
- you have by example this code in source : [b]Hello world![/b]
- then modifiy it to : [b]Hello world![/b
- go in normal mode, change to [b]Hello world![/b]
- go into source, CKeditor fails and you have nothing in edit area
Expected result
The editor shouldn't fails completly
Actual result
The editor fails completly and you that in browser console :
Uncaught TypeError: candidate is null in plugins/bbcode/plugin.js:344:16 onTagClose file:///C:/Users/xillibit/Downloads/ckeditor_4.16.1_41a8791ce01b_source_big/ckeditor/plugins/bbcode/plugin.js:344 parse file:///C:/Users/xillibit/Downloads/ckeditor_4.16.1_41a8791ce01b_source_big/ckeditor/plugins/bbcode/plugin.js:171 fromBBCode file:///C:/Users/xillibit/Downloads/ckeditor_4.16.1_41a8791ce01b_source_big/ckeditor/plugins/bbcode/plugin.js:408 BBCodeToHtml file:///C:/Users/xillibit/Downloads/ckeditor_4.16.1_41a8791ce01b_source_big/ckeditor/plugins/bbcode/plugin.js:588 onSetData file:///C:/Users/xillibit/Downloads/ckeditor_4.16.1_41a8791ce01b_source_big/ckeditor/plugins/bbcode/plugin.js:763 listenerFirer file:///C:/Users/xillibit/Downloads/ckeditor_4.16.1_41a8791ce01b_source_big/ckeditor/core/event.js:169 fire file:///C:/Users/xillibit/Downloads/ckeditor_4.16.1_41a8791ce01b_source_big/ckeditor/core/event.js:313 fire file:///C:/Users/xillibit/Downloads/ckeditor_4.16.1_41a8791ce01b_source_big/ckeditor/core/editor_basic.js:24 setData file:///C:/Users/xillibit/Downloads/ckeditor_4.16.1_41a8791ce01b_source_big/ckeditor/core/editor.js:1152 onLoad file:///C:/Users/xillibit/Downloads/ckeditor_4.16.1_41a8791ce01b_source_big/ckeditor/plugins/wysiwygarea/plugin.js:97 listenerFirer file:///C:/Users/xillibit/Downloads/ckeditor_4.16.1_41a8791ce01b_source_big/ckeditor/core/event.js:169 fire file:///C:/Users/xillibit/Downloads/ckeditor_4.16.1_41a8791ce01b_source_big/ckeditor/core/event.js:313 getNativeListener file:///C:/Users/xillibit/Downloads/ckeditor_4.16.1_41a8791ce01b_source_big/ckeditor/core/dom/domobject.js:46 on file:///C:/Users/xillibit/Downloads/ckeditor_4.16.1_41a8791ce01b_source_big/ckeditor/core/dom/domobject.js:93 init file:///C:/Users/xillibit/Downloads/ckeditor_4.16.1_41a8791ce01b_source_big/ckeditor/plugins/wysiwygarea/plugin.js:52 setMode file:///C:/Users/xillibit/Downloads/ckeditor_4.16.1_41a8791ce01b_source_big/ckeditor/core/creators/themedui.js:225 exec file:///C:/Users/xillibit/Downloads/ckeditor_4.16.1_41a8791ce01b_source_big/ckeditor/plugins/sourcearea/plugin.js:145 exec file:///C:/Users/xillibit/Downloads/ckeditor_4.16.1_41a8791ce01b_source_big/ckeditor/core/command.js:56 execCommand file:///C:/Users/xillibit/Downloads/ckeditor_4.16.1_41a8791ce01b_source_big/ckeditor/core/editor.js:983 click file:///C:/Users/xillibit/Downloads/ckeditor_4.16.1_41a8791ce01b_source_big/ckeditor/plugins/button/plugin.js:87 execute file:///C:/Users/xillibit/Downloads/ckeditor_4.16.1_41a8791ce01b_source_big/ckeditor/plugins/button/plugin.js:165 clickFn file:///C:/Users/xillibit/Downloads/ckeditor_4.16.1_41a8791ce01b_source_big/ckeditor/plugins/button/plugin.js:197 addFunction file:///C:/Users/xillibit/Downloads/ckeditor_4.16.1_41a8791ce01b_source_big/ckeditor/core/tools.js:828 callFunction file:///C:/Users/xillibit/Downloads/ckeditor_4.16.1_41a8791ce01b_source_big/ckeditor/core/tools.js:856 onclick file:///C:/Users/xillibit/Downloads/ckeditor_4.16.1_41a8791ce01b_source_big/ckeditor/samples/index.html:1
Other details
- Browser: Firefox 88.0.1
- OS: Windows 10 21H1
- CKEditor version: 4.16.1
- Installed CKEditor plugins: bbcode
Hi @xillibit ,
Thank you for the report. I try to follow the steps you provide and I'm kind of lost. Could you confirm my version:
1.Put [b]Hello·world![/b as editor content in HTML.
2. Open the editor. The text is bolded, including improper closing bbcode tag [/b
3. Add missing ] to the incorrectly closed tag [/b.
4. Switch to sourcemode.
5. Switch to normal mode.
Now editor hangs with errors in the console.

Yes it's like that, i hadn't added the error showed in the console when the editor hangs. I have added it in my issue above
The source data is interesting in the gif from https://github.com/ckeditor/ckeditor4/issues/4730#issuecomment-849459732:
<b>Hello·world![/b</b>
Since the editor uses bbcode plugin, I think output should contain bbcode only (so [b]) instead of <b> which may mean there is more complex issue somewhere deeper related to how invalid bbcode is parsed :thinking:
@xillibit - thank you for confirmation. Now I can properly label this issue.
@f1ames - definitely looks more complex... I mark it with proper size label :+1:
Probably related to this if not the same: https://github.com/ckeditor/ckeditor4/issues/2782