[wp-trac] [WordPress Trac] #10377: Comment fields should have max lengths

WordPress Trac noreply at wordpress.org
Sat Jan 2 20:47:18 UTC 2016


#10377: Comment fields should have max lengths
---------------------------------------------------+-----------------------
 Reporter:  muriloazevedo                          |       Owner:
     Type:  defect (bug)                           |      Status:  assigned
 Priority:  normal                                 |   Milestone:  4.5
Component:  Comments                               |     Version:  2.8
 Severity:  normal                                 |  Resolution:
 Keywords:  has-patch has-unit-tests dev-feedback  |     Focuses:
---------------------------------------------------+-----------------------

Comment (by azaozz):

 Replying to [comment:25 rachelbaker]:

 10377.4.diff is starting to look good.

 > 1. We could add hardcoded attributes like this to the two other comment
 form inputs.

 Thinking this is a must. Having `maxlength` on the other '''three''' (
 Name, Email, Website ) text fields will improve UX if these limits are
 reached.

 > 2. Is there a good way to convert characters to bytes?

 Nothing that is 100% compatible/reliable afaik. If you want to check the
 byte length of a string, `mb_strlen( $string, '8bit' )` should work well.
 That's the proper way to test it when the "real" mb_strlen() exists. If it
 doesn't exist, the [https://core.trac.wordpress.org/browser/tags/4.4/src
 /wp-includes/compat.php#L105 compat function] will return `strlen( $string
 )`.

 Also this looks like a typo:
 {{{
 } elseif ( is_array( $col_length ) && isset( $col_length['length'] ) &&
 (int) $col_length > 0 ) {
 }}}

 should probably be:
 {{{
 } elseif ( is_array( $col_length ) && isset( $col_length['length'] ) &&
 (int) $col_length['length'] > 0 ) {
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/10377#comment:26>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list