Opened 4 years ago
Closed 3 years ago
#10874 closed enhancement (wontfix)
Use esc_html() instead of htmlspecialchars() when appropriate
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | low | Milestone: | |
| Component: | Security | Version: | 2.9 |
| Severity: | minor | Keywords: | has-patch needs-testing |
| Cc: |
Description
For all htmlspecialchars($string, ENT_QUOTES), we can safely use esc_html(), which is better.
Attachments (1)
Change History (9)
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.
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.
- Priority changed from normal to low
- Severity changed from normal to minor
Note: See
TracTickets for help on using
tickets.

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