Make WordPress Core

Opened 21 months ago

Closed 21 months ago

Last modified 21 months ago

#62952 closed defect (bug) (invalid)

Wrong Escaping functionality in ajax

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

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 21 months ago.
Wrong Escaping functionality in ajax

Download all attachments as: .zip

Change History (6)

#1 @shyamkariya
21 months ago

  • Resolution → wontfix
  • Status new → closed

#2 @shyamkariya
21 months ago

  • Resolution wontfix
  • Status closed → reopened

#3 @ankitkumarshah
21 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
21 months ago

  • Milestone Awaiting Review
  • Resolution → invalid
  • Status reopened → closed

I concur with the above. Thanks!

#5 @sabernhardt
21 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.