[wp-trac] [WordPress Trac] #11054: Users can't post comments if their user-agent header is > 255 characters

WordPress Trac wp-trac at lists.automattic.com
Sat Oct 31 21:56:58 UTC 2009


#11054: Users can't post comments if their user-agent header is > 255 characters
--------------------------+-------------------------------------------------
 Reporter:  mattchiste    |       Owner:       
     Type:  defect (bug)  |      Status:  new  
 Priority:  normal        |   Milestone:       
Component:  General       |     Version:  2.8.5
 Severity:  normal        |    Keywords:       
--------------------------+-------------------------------------------------
 I've posted this to a couple forums but thought I'd post it here.

 http://wordpress.org/support/topic/288615?replies=12#post-1265688

 The problem:  if a user-agent header is > 255 characters, wordpress
 redirects the user to "/wp-comments-post.php#comment-", which is always a
 broken URL.  My user-agent header in IE happens to be "Mozilla/4.0
 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; Trident/4.0; EmbeddedWB
 14.52 from: http://www.bsalsa.com/ EmbeddedWB 14.52; SLCC1; .NET CLR
 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; MS-RTC LM 8;
 OfficeLiveConnector.1.4; OfficeLivePatch.1.3; .NET CLR 3.0.30729)" - 282
 characters.

 The wp_comments table has a comment_agent field with a length of only 255
 characters.

 I suggested this fix on the forums:
 ALTER TABLE `wp`.`wp_comments` MODIFY COLUMN `comment_agent` VARCHAR(512)
 CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;

 ... but ultimately, the real fix would be a tweak to comment.php
 (wp_insert_comment or wp_new_comment functions) so that this line in wp-
 comments-post.php doesn't just get a bad comment ID:
 $comment_id = wp_new_comment( $commentdata );

 ... or if it does, at least these lines check to make sure there's a valid
 comment ID before throwing the redirection:
 $location = empty($_POST['redirect_to']) ? get_comment_link($comment_id) :
 $_POST['redirect_to'] . '#comment-' . $comment_id;
 $location = apply_filters('comment_post_redirect', $location, $comment);

 Thanks

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


More information about the wp-trac mailing list