WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 16 months ago

#43252 closed defect (bug) (fixed)

Extra tabs when quick editing a comment

Reported by: SergeyBiryukov Owned by: SergeyBiryukov
Milestone: 5.1 Priority: normal
Severity: normal Version: 5.1
Component: Comments Keywords: has-patch
Focuses: coding-standards Cc:
PR Number:

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)

43252.diff (1.0 KB) - added by chetan200891 2 years ago.
43252.2.diff (1.2 KB) - added by chetan200891 2 years ago.
43252.3.diff (1.7 KB) - added by chetan200891 2 years ago.

Download all attachments as: .zip

Change History (18)

@chetan200891
2 years ago

#1 @chetan200891
2 years ago

  • Keywords has-patch added

Created patch 43252.diff to remove 4 extra tabs in textarea.

#2 @jrf
2 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>';

Last edited 2 years ago by jrf (previous) (diff)

#3 follow-up: @ocean90
2 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 @jrf
2 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 ;-)

@chetan200891
2 years ago

#5 @chetan200891
2 years ago

@jrf Thanks for your suggestion. I have updated patch!

#6 @jrf
2 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.

@chetan200891
2 years ago

#7 @chetan200891
2 years ago

Yeah @jrf You are right. Updated patch. It looks now more cleaner! :)

#8 @SergeyBiryukov
2 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 42670:

Comments: Avoid extra tabs in a textarea in WP_Comments_List_Table::column_comment().

Props chetan200891, jrf.
Fixes #43252.

#9 @SergeyBiryukov
2 years ago

In 42671:

Options: Avoid extra tabs in a textarea in wp-admin/options.php.

See #43252.

#10 @SergeyBiryukov
2 years ago

In 42672:

Upgrade/Install: Avoid extra line breaks in a textarea in wp-admin/setup-config.php.

See #43252.

#11 @SergeyBiryukov
2 years ago

In 42673:

Customize: Avoid extra tabs in a textarea in WP_Customize_Control::render_content().

See #43252.

#12 @SergeyBiryukov
2 years ago

In 42674:

Posts, Post Types: Remove extra tabs around page_attributes_meta_box_template action in page_attributes_meta_box().

Props chetan200891.
See #43252.

This ticket was mentioned in Slack in #core-docs by drew. View the logs.


2 years ago

#14 @johnbillion
16 months ago

  • Milestone changed from 5.0 to 5.0.1
  • Resolution fixed deleted
  • Status changed from closed to reopened

#15 @SergeyBiryukov
16 months ago

  • Milestone changed from 5.0.1 to 5.1
  • Resolution set to fixed
  • Status changed from reopened to closed

The issues here were caused by [42343] and are only relevant for 5.1.

Note: See TracTickets for help on using tickets.