replace_comment_field_callback autocomplete=”nope” breaks validation
-
Thanks for a nice plugin, it seems to do its job.
I think I stumpled over a tiny bug… The post comment textarea html, sets the autocomplete attribute to “nope”, while the only valid options are “on” and “off”. See snippet below:
<p class=”comment-form-comment”><label for=”comment” class=”screen-reader-text”>Kommentar</label><textarea autocomplete=”nope” id=”e5ee7999a9″ name=”e5ee7999a9″ cols=”45″ rows=”8″ aria-required=”true”>
https://www.w3schools.com/tags/att_input_autocomplete.asp
That breaks otherwise valid html output.
Easy to reproduce. Disable Antispam Bee and the site validates, enable and the error re-occurs.
The culprit seems to be this function
/** * The callback function for the preg_match_callback to modify the textarea tags. * * @since 2.6.10 * * @param array $matches The regex matches. * * @return string The modified content string. */ public static function replace_comment_field_callback( $matches ) { if ( self::get_option( 'time_check' ) ) { $init_time_field = sprintf( '<input type="hidden" name="ab_init_time" value="%d" />', time() ); } else { $init_time_field = ''; } $output = '<textarea autocomplete="nope" ' . $matches['before1'] . $matches['before2'] . $matches['before3']; $id_script = ''; if ( ! empty( $matches['id1'] ) || ! empty( $matches['id2'] ) ) { $output .= 'id="' . self::get_secret_id_for_post( self::$_current_post_id ) . '" '; $id_script = '<script type="text/javascript">document.getElementById("comment").setAttribute( "id", "a' . substr( esc_js( md5( time() ) ), 0, 31 ) . '" );document.getElementById("' . esc_js( self::get_secret_id_for_post( self::$_current_post_id ) ) . '").setAttribute( "id", "comment" );</script>'; } $output .= ' name="' . esc_attr( self::get_secret_name_for_post( self::$_current_post_id ) ) . '" '; $output .= $matches['between1'] . $matches['between2'] . $matches['between3']; $output .= $matches['after'] . '>'; $output .= $matches['content']; $output .= '</textarea><textarea id="comment" aria-hidden="true" name="comment" autocomplete="nope" style="padding:0;clip:rect(1px, 1px, 1px, 1px);position:absolute !important;white-space:nowrap;height:1px;width:1px;overflow:hidden;" tabindex="-1"></textarea>'; $output .= $id_script; $output .= $init_time_field; return $output; }After changing autocomplete=”nope” to autocomplete=”off” the site validates.
Best regards
Bjarne OldrupThe page I need help with: [log in to see the link]
The topic ‘replace_comment_field_callback autocomplete=”nope” breaks validation’ is closed to new replies.