Make WordPress Core


Ignore:
Timestamp:
01/13/2016 01:24:46 AM (10 years ago)
Author:
rachelbaker
Message:

Comments: Restrict the maximum characters for input fields within the comments template.

Added hardcoded maxlength attributes on the author, author_email, author_url, and comment_field input markup. These can be modified via the comment_form_defaults filter. Added logic in wp_handle_comment_submission() to return a WP_Error when the comment_author, comment_author_url, or comment_content values exceed the max length of their columns. Introduces wp_get_comment_column_max_length() which returns the max column length for a given column name, and is filterable. Unit tests included for the error conditions in wp_handle_comment_submission()

Fixes #10377.

Props westonruter rachelbaker.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/utils.php

    r36243 r36272  
    55function rand_str($len=32) {
    66    return substr(md5(uniqid(rand())), 0, $len);
     7}
     8
     9function rand_long_str( $length ) {
     10    $chars = 'abcdefghijklmnopqrstuvwxyz';
     11    $string = '';
     12
     13    for ( $i = 0; $i < $length; $i++ ) {
     14        $rand = rand( 0, strlen( $chars ) - 1 );
     15        $string .= substr( $chars, $rand, 1 );
     16    }
     17
     18    return $string;
    719}
    820
Note: See TracChangeset for help on using the changeset viewer.