WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#3946 closed defect (bug) (invalid)

TinyMCE converts strong & em to b & i without checking full tag.

Reported by: Linusmartensson Owned by: andy
Milestone: Priority: normal
Severity: normal Version:
Component: TinyMCE Keywords: dev-feedback
Focuses: 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 foolswisdom7 years ago

  • Milestone changed from 2.1.3 to 2.2
  • Version set to 2.1.2

comment:2 rob1n7 years ago

  • Owner changed from anonymous to andy

comment:3 foolswisdom7 years ago

  • Milestone changed from 2.2 to 2.4

comment:4 follow-up: chmac7 years ago

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.

comment:5 in reply to: ↑ 4 thee177 years ago

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?

comment:6 thee177 years ago

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');
	}

comment:7 thee177 years ago

  • Keywords dev-feedback added

comment:8 Otto427 years ago

  • 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.

comment:9 Otto427 years ago

  • Milestone 2.4 deleted
  • Version 2.1.2 deleted
Note: See TracTickets for help on using tickets.