[wp-trac] [WordPress Trac] #64457: Avoid underscores for hosts in wp_http_validate_url
WordPress Trac
noreply at wordpress.org
Mon Dec 29 06:19:00 UTC 2025
#64457: Avoid underscores for hosts in wp_http_validate_url
-------------------------+------------------------------
Reporter: SirLouen | Owner: (none)
Type: enhancement | Status: new
Priority: low | Milestone: Awaiting Review
Component: HTTP API | Version:
Severity: normal | Resolution:
Keywords: 2nd-opinion | Focuses: performance
-------------------------+------------------------------
Comment (by manhphucofficial):
That’s a fair question, and I agree with the underlying point.
The reason the ticket originally mentions underscores specifically is
mostly practical: `_` is a very common mistake in hostnames, and it’s a
case where we can be confident that `gethostbyname()` will never succeed.
So the idea was to avoid that call early in an obviously invalid case,
purely as a small performance win.
But you’re right that, once we start thinking about this more generally,
singling out underscores feels a bit arbitrary. If we’re going to short-
circuit at this stage, it probably makes more sense to do a broader “is
this a valid hostname at all?” check and bail early for any disallowed
characters, rather than hard-coding one specific case.
I’m open to adjusting the scope of the ticket in that direction if that’s
the better approach.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64457#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list