[wp-trac] Re: [WordPress Trac] #3826: TinyMCE misconfiguration causes erronous tag replacements

WordPress Trac wp-trac at lists.automattic.com
Sun Mar 4 23:55:04 GMT 2007


#3826: TinyMCE misconfiguration causes erronous tag replacements
------------------------+---------------------------------------------------
 Reporter:  novasource  |        Owner:  anonymous
     Type:  defect      |       Status:  new      
 Priority:  normal      |    Milestone:  2.1.3    
Component:  TinyMCE     |      Version:  2.1      
 Severity:  normal      |   Resolution:           
 Keywords:              |  
------------------------+---------------------------------------------------
Changes (by linusmartensson):

  * summary:  Editor replaces div with p including the div's class, several
              other tags are also replaced in a similar
              fashion => TinyMCE misconfiguration causes
              erronous tag replacements
  * milestone:  2.2 => 2.1.3

Comment:

 On second thought, I looked into this a bit over at
 http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/valid_elements

 Turns out this is just a TinyMCE malconfiguration.

 Here's the current code:
 {{{
 // Set up init variables
 $valid_elements =
 'p/-div[*],-strong/-b[*],-em/-i[*],-font[*],-ul[*],-ol[*],-li[*],*[*]';
 $valid_elements = apply_filters('mce_valid_elements', $valid_elements);
 }}}

 I'd recommend rewriting it to use negation rather than approval, seeing as
 *[*] is added at the end, which approves all elements anyhow. Not to
 mention the text editor would allow illegal statements in any case as long
 as the visual editor is disabled.

 tiny_mce_config.php:
 {{{
 $valid_elements = '*[*]';
 $valid_elements = apply_filters('mce_valid_elements', $valid_elements);
 $invalid elements = apply_filters('mce_invalid_elements', '');
 }}}

 Then you'd add this line to the init section:
 {{{
 invalid_elements : "<?php echo $invalid_elements; ?>",
 }}}

 Now you could just add basic filters to set up the valid / invalid
 elements without strange configurations confusing users.

 Linus

-- 
Ticket URL: <http://trac.wordpress.org/ticket/3826#comment:4>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list