This hack was originally added to wfParseUrl
as a fix for T10324 specifically for LinkFilter,
however according to the RFC 3986 this is wrong.
RFC defines that in URLs the authority component
must start with //, so in urls without //, e.g. news:
or mailto: there is no authority component, and thus
no host component, everything after : is actually a path,
so default PHP parse_url is correct.
RFC even has an example:
> For example, the URI <mailto:fred@example.com>
has a path of "fred@example.com".
It's fairly ugly to just copy-paste the hack
into LinkFilter, but I didn't find an easy and
elegant way to rewrite it without making any
changes to the link indexes values stored in the DB.
See https://datatracker.ietf.org/doc/html/rfc3986
Co-Authored-by: 沈澄心 <dringsim@qq.com>
Change-Id: I3dd04495db9c7a66f62c3914c0eff06754b7d560
Follows-up 472a914c63 (I706ef8a50aafb51), which moved various
functions here en-mass, but these two don't require any state.
The warnings about parse_url() in UrlUtils.php have been obsolete
since about PHP 5.4, when it started to support protocol-relative
URLs, non-slash protocols like "mailto", and deal with spaces/newlines
correctly (https://3v4l.org/YWUkl).
Rather than complicate many components that would otherwise remain
stateless and unit-testable, fix these to once again be the static
functions they were.
For impact, see upto PS17 of change I5117eab95f57297eb02bed.
Bug: T227900
Change-Id: Ifb3f720fc429b107348644c98eb9cd8e1113a42a
phpunit --filter UrlUtilsTest would execute no tests because the class
was already loaded by the GlobalFunctions data providers via the
autoloader, so PHPUnit sees no additional classes when it examines
UrlUtilsTest.php.
So, split out all providers in UrlUtilsTest to a separate class which
can be safely autoloaded.
Change-Id: I483736ee70e598cdb19f8203bc6885f1c234fc42
The new class, UrlUtils, is usable standalone or as a service. Using it
as a service will just automatically load a few settings from site
configuration.
In addition to just making our code cleaner, this will enable making
some of Setup.php's dynamic configuration more sane.
Test coverage is all lines except invalid URLs -- I couldn't find any.
Bug: T305093
Change-Id: I706ef8a50aafb518e13222719575d274c3583b90