[wp-trac] Re: [WordPress Trac] #6099: WordPress Filters Not Properly
Converting Newline Characters When Submitting Via AJAX
WordPress Trac
wp-trac at lists.automattic.com
Thu Mar 6 01:03:52 GMT 2008
#6099: WordPress Filters Not Properly Converting Newline Characters When
Submitting Via AJAX
---------------------+------------------------------------------------------
Reporter: ronalfy | Owner: anonymous
Type: defect | Status: reopened
Priority: normal | Milestone:
Component: General | Version: 2.5
Severity: major | Resolution:
Keywords: |
---------------------+------------------------------------------------------
Changes (by ronalfy):
* status: closed => reopened
* resolution: invalid =>
Comment:
Mark,
I'm using the jQuery supplied with WordPress and the plugin I wrote called
Ajax Edit Comments. I've modified my code to mimic exactly how WordPress
edits its own comments.
Using the example I provided, here's what gets sent via AJAX:
{{{
Paragraph 1 :)\n\nParagraph 2 :)\n\nParagraph 3
}}}
I then get the original comment, decode the passed text, and update the
original comment with the new text. I then update the comment using WP's
built in function:
{{{
$comment = get_comment($id, ARRAY_A);
$content = urldecode($content);
$comment['comment_content'] = $content;
wp_update_comment($comment);
}}}
Within the '''wp_update_comment''' function are two filters that are run
on the new comment content. These two filter are
'''pre_comment_content''' and '''comment_save_pre'''. If I run these two
filters on the passed text, it returns this code:
{{{
Test Paragraph 1 :)\n\nTest Paragraph 2 :)\n\nTest Paragraph 33
}}}
The two filters are run and produce identical results to what's passed via
AJAX.
Then of course the filter '''comment_text''' gets applied, and you get the
final resulting code:
{{{
<p>Test Paragraph 1 <img src='http://127.0.0.1/raproject/wp-
includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br
/>\nTest Paragraph 2 <img src='http://127.0.0.1/raproject/wp-
includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br
/>\nTest Paragraph 3</p>\n
}}}
So the culprit I believe lies with the '''comment_text''' filter when
smilies and some other characters are inserted with a comment.
This behavior happens on other AJAX related comments such as Absolute
Comments, Better Comments Manager, and AJAX Comments. All have the
common-denominator of the 'comment_text' filter.
--
Ticket URL: <http://trac.wordpress.org/ticket/6099#comment:2>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list