[wp-trac] [WordPress Trac] #6099: WordPress Filters Not Properly Converting Newline Characters When Submitting Via AJAX

WordPress Trac wp-trac at lists.automattic.com
Wed Mar 5 05:18:30 GMT 2008


#6099: WordPress Filters Not Properly Converting Newline Characters When
Submitting Via AJAX
---------------------+------------------------------------------------------
 Reporter:  ronalfy  |       Owner:  anonymous
     Type:  defect   |      Status:  new      
 Priority:  normal   |   Milestone:  2.6      
Component:  General  |     Version:  2.5      
 Severity:  major    |    Keywords:           
---------------------+------------------------------------------------------
 I've observed some odd behavior on plugins that submit content via AJAX,
 most notably comments.  The problem is not with the plugins themselves,
 per se, but rather the way WordPress filters the content.

 Here is an example of a comment submitted:

 {{{
 Paragraph 1 :)

 Paragraph 2 :)

 Paragraph 3
 }}}

 In a post the comment's HTML is:

 {{{
 <p>
 Paragraph 1
 <img class="wp-smiley" alt=":)" src="http://127.0.0.1/latest/wp-
 includes/images/smilies/icon_smile.gif"/>
 </p>
 <p>
 Paragraph 2
 <img class="wp-smiley" alt=":)" src="http://127.0.0.1/latest/wp-
 includes/images/smilies/icon_smile.gif"/>
 </p>
 <p>Paragraph 3</p>
 }}}

 However, if one was to post the same comment or edit the comment via AJAX,
 the resulting code would be:

 {{{
 <p>
 Paragraph 1
 <img class="wp-smiley" alt=":)" src="http://127.0.0.1/latest/wp-
 includes/images/smilies/icon_smile.gif"/>
 <br/>
 Paragraph 2
 <img class="wp-smiley" alt=":)" src="http://127.0.0.1/latest/wp-
 includes/images/smilies/icon_smile.gif"/>
 <br/>
 Paragraph 3
 </p>
 }}}

 The culprit could easily be the plugin, however, the code I'm currently
 using is the exact same used when editing a comment using the normal form
 method, which is to call the '''wp_update_comment''' method.

 When saving the above comment, the code that the JavaScript sends is:

 {{{
 Paragraph 1 :)\n\nParagraph 2 :)\n\nParagraph 3
 }}}

 Somewhere along the way, the extra newlines are being lost in translation
 and being converted into BRs instead of new paragraphs.

-- 
Ticket URL: <http://trac.wordpress.org/ticket/6099>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list