[wp-trac] [WordPress Trac] #63625: esc_url
WordPress Trac
noreply at wordpress.org
Thu Jun 26 17:30:30 UTC 2025
#63625: esc_url
------------------------------+-----------------------------
Reporter: alexanderkoledov | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 6.8
Severity: normal | Keywords: has-patch
Focuses: |
------------------------------+-----------------------------
Hi,
We have esc_url function that expects a string as an argument for ltrim to
work correctly. Before php 8, when receiving an array, this did not cause
a Fatal Error. How about protecting yourself from a Fatal error and a site
crash, for example, like this
{{{#!php
<?php
function esc_url( $url, $protocols = null, $_context = 'display' ) {
if ( ! is_string( $url ) ) {
return '';
}
$url = ltrim( $url );
// ...
}
}}}
Yes, I understand that this may look like a masking of the problem and in
the end passing correct data to the function is a task that the developer
should take care of, but here I think the gain from reliability is
greater. Given that WordPress strives for backward compatibility and
developer convenience, I believe this small adjustment would improve
overall reliability and user experience.
Thanks for considering.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63625>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list