Make WordPress Core

Opened 2 months ago

Closed 2 months ago

Last modified 2 months ago

#62952 closed defect (bug) (invalid)

Wrong Escaping functionality in ajax

Reported by: rajdiptank111's profile rajdiptank111 Owned by:
Milestone: Priority: normal
Severity: normal Version: 6.7.2
Component: General Keywords: has-screenshots
Focuses: javascript, administration, coding-standards, php-compatibility Cc:

Description

Wrong Escaping functionality ajax-actions.php file... missing Escaping functionality is esc_html( $url ).

File Location:- ...\wp-admin\includes\ajax-actions.php file line number 3822.

I have shared the screenshot below...

Attachments (1)

ajax-actions-esc_html-to-esc_url.png (12.8 KB) - added by rajdiptank111 2 months ago.
Wrong Escaping functionality in ajax

Download all attachments as: .zip

Change History (6)

@rajdiptank111
2 months ago

Wrong Escaping functionality in ajax

#1 @shyamkariya
2 months ago

  • Resolution set to wontfix
  • Status changed from new to closed

#2 @shyamkariya
2 months ago

  • Resolution wontfix deleted
  • Status changed from closed to reopened

#3 @ankitkumarshah
2 months ago

  • Keywords has-patch changes-requested removed

Hi @rajdiptank111,

Thank you for bringing this up!

For this case, using esc_html() is appropriate. The URL is being displayed inside a <code> tag as part of an error message, not being used as an actual URL in a link or form action.

If this URL was being used in an href attribute or anywhere where an actual URL is required, then you would want to use esc_url(). But since this is purely for display purposes inside a code tag in an error message, esc_html() is the correct choice here.

#4 @johnbillion
2 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from reopened to closed

I concur with the above. Thanks!

#5 @sabernhardt
2 months ago

[43290] has a good example of when to use each function:

<a href="<?php echo esc_url( $comment_link ); ?>">
	<?php echo esc_html( $comment_link ); ?>
</a>
Note: See TracTickets for help on using tickets.