Opened 7 years ago
Closed 6 years ago
#43252 closed defect (bug) (fixed)
Extra tabs when quick editing a comment
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 5.1 | Priority: | normal |
Severity: | normal | Version: | 5.1 |
Component: | Comments | Keywords: | has-patch |
Focuses: | coding-standards | Cc: |
Description
When quick editing a comment, there are 4 extra tabs in the textarea: 2 before the comment content and 2 after.
Caused by [42343], which changed this:
<textarea class="comment" rows="1" cols="1"><?php /** This filter is documented in wp-admin/includes/comment.php */ echo esc_textarea( apply_filters( 'comment_edit_pre', $comment->comment_content ) ); ?></textarea>
to this:
<textarea class="comment" rows="1" cols="1"> <?php /** This filter is documented in wp-admin/includes/comment.php */ echo esc_textarea( apply_filters( 'comment_edit_pre', $comment->comment_content ) ); ?> </textarea>
Might be a good idea to review other <textarea>
instances in core as well.
Attachments (3)
Change History (18)
#2
@
7 years ago
I agree this should be reverted and shouldn't have been changed in the first place, however, it was changed because of an underlying issue, i.e. HTML entities not being escaped in the text being passed to the editor.
IMO, the patch should be updated to properly escape the entities, like below:
Actually, I was too quick in my response and missed that the textarea wasn't intended to display the php code for editing. Sorry about that.
So, reboot.
Looking at the code properly, IMO, it should be changed as follows:
<?php /** This filter is documented in wp-admin/includes/comment.php */ $filtered_comment = apply_filters( 'comment_edit_pre', $comment->comment_content ); ?> <textarea class="comment" rows="1" cols="1"><?php echo esc_textarea( $filtered_comment ); ?></textarea>
Or alternatively, don't bother with the inline HTML at all:
<?php <?php echo '<textarea class="comment" rows="1" cols="1">'; /** This filter is documented in wp-admin/includes/comment.php */ echo esc_textarea( apply_filters( 'comment_edit_pre', $comment->comment_content ) ); echo '</textarea>';
#3
follow-up:
↓ 4
@
7 years ago
@jrf I think you misread the code somehow. We don't want the PHP code displayed in the textarea, it should be the comment content.
#4
in reply to:
↑ 3
@
7 years ago
Replying to ocean90:
@jrf I think you misread the code somehow. We don't want the PHP code displayed in the textarea, it should be the comment content.
Yup, already edited my original response. Sorry about that ;-)
#6
@
7 years ago
@chetan200891 👍
Looking at the complete function, I think the setting of the variable/apply_filters()
function call could even be moved up a little more to just below the if ( $this->user_can ) {
.
That way, the HTML block looks cleaner, but it's no biggy.
#8
@
7 years ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed
In 42670:
Created patch 43252.diff to remove 4 extra tabs in textarea.