#3946 closed defect (bug) (invalid)
TinyMCE converts strong & em to b & i without checking full tag.
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | TinyMCE | Version: | |
| Severity: | normal | Keywords: | dev-feedback |
| Cc: |
Description
I thought this to be a different bug at first, reading the TinyMCE source a bit proved me wrong.
Here's the relevant section:
// Convert all strong/em to b/i in Gecko
if (tinyMCE.isGecko) {
h = h.replace(/<strong/gi, '<b');
h = h.replace(/<em(\/?)/gi, '<i');
h = h.replace(/<em /gi, '<i');
h = h.replace(/<\/strong>/gi, '</b>');
h = h.replace(/<\/em>/gi, '</i>');
}
This is at line 5100 in tiny_mce.js
This is a perpetrator in the cases where <embed> is replaced with <ibed>.
I'm not sure what reasons there are for this replacement within gecko, but I propse adding a whitespace check to the open versions of the tags - merging some of the regexp expressions should also be possible - to avoid trashing embed tags.
Change History (9)
comment:1
foolswisdom — 6 years ago
- Milestone changed from 2.1.3 to 2.2
- Version set to 2.1.2
comment:3
foolswisdom — 6 years ago
- Milestone changed from 2.2 to 2.4
According to the TinyMCE tracker this was fixed in January.
https://sourceforge.net/tracker/index.php?func=detail&aid=1641826&group_id=103281&atid=635682
Are we possibly not using a current version?
On second though, what if we changed the above to:
// Convert all strong/em to b/i in Gecko
if (tinyMCE.isGecko) {
h = h.replace(/<strong/gi, '<b');
h = h.replace(/<em(\/?)/gi, '<i');
h = h.replace(/<em /gi, '<i');
h = h.replace(/<\/strong>/gi, '</b>');
h = h.replace(/<\/em>/gi, '</i>');
h = h.replace(/<\/ibed>/gi, '</embed>');
h = h.replace(/<ibed /gi, '<embed');
}
- Resolution set to invalid
- Status changed from new to closed
This should already be fixed in trunk, as it's using a later version of TinyMCE.

Hey Linusmartensson,
Are you a Javascript / regex guru? I'm definitely not, so I'm not exactly sure what would need to be changed. But it seems like a pretty simple change, given my limited knowledge of regex (assuming of course it is a regex!).
I think we'd need to check for a few possibilities:
+ Tag followed by whitespace
+ Tag followed by forwardslash less-than "/>"
+ Tag followed by less-than ">"
Are there any other possibilities?
This is a pretty significant problem. If you paste an EMBED tag into your code view and then edit the post, it converts the tags and ruins your lovely video!
Cheers - Callum.