Make WordPress Core

Opened 16 years ago

Closed 15 years ago

#10874 closed enhancement (wontfix)

Use esc_html() instead of htmlspecialchars() when appropriate

Reported by: scribu's profile scribu Owned by: ryan's profile ryan
Milestone: Priority: low
Severity: minor Version: 2.9
Component: Security Keywords: has-patch needs-testing
Focuses: Cc:

Description

For all htmlspecialchars($string, ENT_QUOTES), we can safely use esc_html(), which is better.

Attachments (1)

esc_html.diff (2.1 KB) - added by scribu 16 years ago.

Download all attachments as: .zip

Change History (9)

@scribu
16 years ago

#1 @scribu
16 years ago

  • Keywords has-patch needs-testing added

#2 @ryan
16 years ago

Can we use esc_html() in wp-db.php? I'm not sure formatting.php is loaded for all situations.

#3 @azaozz
16 years ago

esc_html() is a display filter, main difference from htmlspecialchars() is that it doesn't double-encode some html entities and always encodes all quotes. However when loading text to edit double-encoding is usually needed.

#4 @hakre
16 years ago

There is no general rule that says esc_html() is better then htmlspecialchars. Using htmlspecialchars where appropriate is perfectly valid. It has less overhead for example and does a great job as well as it is properly tested.

#5 @ryan
16 years ago

  • Milestone changed from 2.9 to Future Release

#6 @lloydbudd
16 years ago

  • Component changed from General to Security
  • Owner set to ryan

#7 @lloydbudd
16 years ago

  • Priority changed from normal to low
  • Severity changed from normal to minor

#8 @scribu
15 years ago

  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.