diff options
-rw-r--r-- | docs/config-schema.yaml | 4 | ||||
-rw-r--r-- | includes/Feed/AtomFeed.php | 2 | ||||
-rw-r--r-- | includes/MainConfigSchema.php | 4 | ||||
-rw-r--r-- | includes/Request/ContentSecurityPolicy.php | 4 | ||||
-rw-r--r-- | includes/WikiMap/WikiMap.php | 12 | ||||
-rw-r--r-- | includes/deferred/CdnCacheUpdate.php | 2 | ||||
-rw-r--r-- | includes/editpage/IntroMessageBuilder.php | 9 | ||||
-rw-r--r-- | includes/http/MWHttpRequest.php | 6 | ||||
-rw-r--r-- | includes/jobqueue/jobs/ThumbnailRenderJob.php | 2 | ||||
-rw-r--r-- | includes/parser/Parser.php | 5 | ||||
-rw-r--r-- | includes/recentchanges/RCFeed/RedisPubSubFeedEngine.php | 3 | ||||
-rw-r--r-- | includes/search/searchwidgets/InterwikiSearchResultSetWidget.php | 3 | ||||
-rw-r--r-- | includes/upload/UploadFromUrl.php | 2 | ||||
-rw-r--r-- | tests/parser/legacyMedia.txt | 2 | ||||
-rw-r--r-- | tests/parser/media.txt | 2 |
15 files changed, 35 insertions, 27 deletions
diff --git a/docs/config-schema.yaml b/docs/config-schema.yaml index e67c7af545c6..6f3bef7543d0 100644 --- a/docs/config-schema.yaml +++ b/docs/config-schema.yaml @@ -4111,12 +4111,12 @@ config-schema: - // type: array description: |- - URL schemes that should be recognized as valid by wfParseUrl(). + URL schemes that should be recognized as valid by UrlUtils::parse(). WARNING: Do not add 'file:' to this or internal file links will be broken. Instead, if you want to support file links, add 'file://'. The same applies to any other protocols with the same name as a namespace. See task T46011 for more information. - @see \wfParseUrl + @see \MediaWiki\Utils\UrlUtils::parse() CleanSignatures: default: true description: 'If true, removes (by substituting) templates in signatures.' diff --git a/includes/Feed/AtomFeed.php b/includes/Feed/AtomFeed.php index 61ee80d51102..453943a39f75 100644 --- a/includes/Feed/AtomFeed.php +++ b/includes/Feed/AtomFeed.php @@ -75,6 +75,7 @@ class AtomFeed extends ChannelFeed { /** * Atom 1.0 requests a self-reference to the feed. + * * @return string */ private function getSelfUrl() { @@ -84,6 +85,7 @@ class AtomFeed extends ChannelFeed { /** * Output a given item. + * * @param FeedItem $item */ public function outItem( $item ) { diff --git a/includes/MainConfigSchema.php b/includes/MainConfigSchema.php index b8b9c6989079..f9a3e9bcd619 100644 --- a/includes/MainConfigSchema.php +++ b/includes/MainConfigSchema.php @@ -6430,14 +6430,14 @@ class MainConfigSchema { ]; /** - * URL schemes that should be recognized as valid by wfParseUrl(). + * URL schemes that should be recognized as valid by UrlUtils::parse(). * * WARNING: Do not add 'file:' to this or internal file links will be broken. * Instead, if you want to support file links, add 'file://'. The same applies * to any other protocols with the same name as a namespace. See task T46011 for * more information. * - * @see \wfParseUrl + * @see \MediaWiki\Utils\UrlUtils::parse() */ public const UrlProtocols = [ 'default' => [ diff --git a/includes/Request/ContentSecurityPolicy.php b/includes/Request/ContentSecurityPolicy.php index 73b62dedd4b2..ca5c650aa166 100644 --- a/includes/Request/ContentSecurityPolicy.php +++ b/includes/Request/ContentSecurityPolicy.php @@ -334,12 +334,12 @@ class ContentSecurityPolicy { // A schema source (e.g. blob: or data:) return $url; } - $bits = wfParseUrl( $url ); + $bits = wfGetUrlUtils()->parse( $url ); if ( !$bits && strpos( $url, '/' ) === false ) { // probably something like example.com. // try again protocol-relative. $url = '//' . $url; - $bits = wfParseUrl( $url ); + $bits = wfGetUrlUtils()->parse( $url ); } if ( $bits && isset( $bits['host'] ) && $bits['host'] !== $this->mwConfig->get( MainConfigNames::ServerName ) diff --git a/includes/WikiMap/WikiMap.php b/includes/WikiMap/WikiMap.php index ae24197261e5..c9fb22d58ec2 100644 --- a/includes/WikiMap/WikiMap.php +++ b/includes/WikiMap/WikiMap.php @@ -95,8 +95,8 @@ class WikiMap { return null; } - $urlParts = wfParseUrl( $site->getPageUrl() ); - if ( $urlParts === false || !isset( $urlParts['path'] ) || !isset( $urlParts['host'] ) ) { + $urlParts = wfGetUrlUtils()->parse( $site->getPageUrl() ); + if ( $urlParts === null || !isset( $urlParts['path'] ) || !isset( $urlParts['host'] ) ) { // We can't create a meaningful WikiReference without URLs return null; } @@ -208,14 +208,14 @@ class WikiMap { $wikiId = self::getCurrentWikiId(); $infoMap[$wikiId] = [ 'url' => $wgCanonicalServer, - 'parts' => wfParseUrl( $wgCanonicalServer ) + 'parts' => wfGetUrlUtils()->parse( $wgCanonicalServer ) ]; foreach ( $wgLocalDatabases as $wikiId ) { $wikiReference = self::getWiki( $wikiId ); if ( $wikiReference ) { $url = $wikiReference->getCanonicalServer(); - $infoMap[$wikiId] = [ 'url' => $url, 'parts' => wfParseUrl( $url ) ]; + $infoMap[$wikiId] = [ 'url' => $url, 'parts' => wfGetUrlUtils()->parse( $url ) ]; } } @@ -238,8 +238,8 @@ class WikiMap { return self::getCurrentWikiId(); } - $urlPartsCheck = wfParseUrl( $url ); - if ( $urlPartsCheck === false ) { + $urlPartsCheck = wfGetUrlUtils()->parse( $url ); + if ( $urlPartsCheck === null ) { return false; } diff --git a/includes/deferred/CdnCacheUpdate.php b/includes/deferred/CdnCacheUpdate.php index 798837d668df..8c788ea248b4 100644 --- a/includes/deferred/CdnCacheUpdate.php +++ b/includes/deferred/CdnCacheUpdate.php @@ -292,7 +292,7 @@ class CdnCacheUpdate implements DeferrableUpdate, MergeableUpdate { $reqs = []; foreach ( $urls as $url ) { $url = self::expand( $url ); - $urlInfo = wfParseUrl( $url ); + $urlInfo = wfGetUrlUtils()->parse( $url ) ?? false; $urlHost = strlen( $urlInfo['port'] ?? '' ) ? IPUtils::combineHostAndPort( $urlInfo['host'], (int)$urlInfo['port'] ) : $urlInfo['host']; diff --git a/includes/editpage/IntroMessageBuilder.php b/includes/editpage/IntroMessageBuilder.php index ba6d5e048305..332ebb518beb 100644 --- a/includes/editpage/IntroMessageBuilder.php +++ b/includes/editpage/IntroMessageBuilder.php @@ -413,9 +413,12 @@ class IntroMessageBuilder { } if ( !$page->exists() ) { - $helpLink = $this->urlUtils->expand( Skin::makeInternalOrExternalUrl( - $localizer->msg( 'helppage' )->inContentLanguage()->text() - ), PROTO_CURRENT ); + $helpLink = $this->urlUtils->expand( + Skin::makeInternalOrExternalUrl( + $localizer->msg( 'helppage' )->inContentLanguage()->text() + ), + PROTO_CURRENT + ); if ( $performer->getUser()->isRegistered() ) { $messages->add( $localizer->msg( 'newarticletext', $helpLink ), diff --git a/includes/http/MWHttpRequest.php b/includes/http/MWHttpRequest.php index fe650ea4261a..b0e61f56f332 100644 --- a/includes/http/MWHttpRequest.php +++ b/includes/http/MWHttpRequest.php @@ -250,8 +250,8 @@ abstract class MWHttpRequest implements LoggerAwareInterface { * @param string $proxy URL of proxy */ protected function setReverseProxy( string $proxy ) { - $parsedProxy = $this->urlUtils->parse( $proxy ) ?? false; - if ( $parsedProxy === false ) { + $parsedProxy = $this->urlUtils->parse( $proxy ); + if ( $parsedProxy === null ) { throw new InvalidArgumentException( "Invalid reverseProxy configured: $proxy" ); } // Set the current host in the Host header @@ -264,7 +264,7 @@ abstract class MWHttpRequest implements LoggerAwareInterface { } else { unset( $this->parsedUrl['port'] ); } - $this->url = UrlUtils::assemble( (array)$this->parsedUrl ); + $this->url = UrlUtils::assemble( $this->parsedUrl ); // Mark that we're already using a proxy $this->noProxy = true; } diff --git a/includes/jobqueue/jobs/ThumbnailRenderJob.php b/includes/jobqueue/jobs/ThumbnailRenderJob.php index 2a4ca491f902..1c0fb18bfd9f 100644 --- a/includes/jobqueue/jobs/ThumbnailRenderJob.php +++ b/includes/jobqueue/jobs/ThumbnailRenderJob.php @@ -101,7 +101,7 @@ class ThumbnailRenderJob extends Job { } if ( $uploadThumbnailRenderHttpCustomDomain ) { - $parsedUrl = wfParseUrl( $thumbUrl ); + $parsedUrl = wfGetUrlUtils()->parse( $thumbUrl ); if ( !isset( $parsedUrl['path'] ) || $parsedUrl['path'] === '' ) { $this->setLastError( __METHOD__ . ": invalid thumb URL: $thumbUrl" ); diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 47449fd943d7..068806a8ea86 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -2271,8 +2271,9 @@ class Parser { $noFollowNsExceptions = $mainConfig->get( MainConfigNames::NoFollowNsExceptions ); $noFollowDomainExceptions = $mainConfig->get( MainConfigNames::NoFollowDomainExceptions ); $ns = $title ? $title->getNamespace() : false; - if ( $noFollowLinks && !in_array( $ns, $noFollowNsExceptions ) - && !wfMatchesDomainList( $url, $noFollowDomainExceptions ) + if ( + $noFollowLinks && !in_array( $ns, $noFollowNsExceptions ) + && !wfGetUrlUtils()->matchesDomainList( (string)$url, $noFollowDomainExceptions ) ) { return 'nofollow'; } diff --git a/includes/recentchanges/RCFeed/RedisPubSubFeedEngine.php b/includes/recentchanges/RCFeed/RedisPubSubFeedEngine.php index be789bd3d43e..0074e1437582 100644 --- a/includes/recentchanges/RCFeed/RedisPubSubFeedEngine.php +++ b/includes/recentchanges/RCFeed/RedisPubSubFeedEngine.php @@ -57,7 +57,8 @@ class RedisPubSubFeedEngine extends FormattedRCFeed { * @return bool */ public function send( array $feed, $line ) { - $parsed = wfParseUrl( $feed['uri'] ); + $parsed = wfGetUrlUtils()->parse( $feed['uri'] ); + // @phan-suppress-next-line PhanTypeArraySuspiciousNullable Valid URL $server = $parsed['host']; $options = [ 'serializer' => 'none' ]; $channel = 'rc'; diff --git a/includes/search/searchwidgets/InterwikiSearchResultSetWidget.php b/includes/search/searchwidgets/InterwikiSearchResultSetWidget.php index 1608dfbeea18..508fc4885603 100644 --- a/includes/search/searchwidgets/InterwikiSearchResultSetWidget.php +++ b/includes/search/searchwidgets/InterwikiSearchResultSetWidget.php @@ -225,7 +225,8 @@ class InterwikiSearchResultSetWidget implements SearchResultSetWidget { * @return OOUI\IconWidget */ protected function generateIconFromFavicon( $logoUrl ) { - $parsed = wfParseUrl( wfExpandUrl( $logoUrl ) ); + $parsed = wfGetUrlUtils()->parse( (string)wfGetUrlUtils()->expand( $logoUrl, PROTO_CURRENT ) ); + '@phan-var array $parsed'; // Valid URL $iwIconUrl = $parsed['scheme'] . $parsed['delimiter'] . $parsed['host'] . diff --git a/includes/upload/UploadFromUrl.php b/includes/upload/UploadFromUrl.php index 17fa7aed2331..25ecaafcdb7c 100644 --- a/includes/upload/UploadFromUrl.php +++ b/includes/upload/UploadFromUrl.php @@ -87,7 +87,7 @@ class UploadFromUrl extends UploadBase { if ( !count( $domains ) ) { return true; } - $parsedUrl = wfParseUrl( $url ); + $parsedUrl = wfGetUrlUtils()->parse( $url ); if ( !$parsedUrl ) { return false; } diff --git a/tests/parser/legacyMedia.txt b/tests/parser/legacyMedia.txt index 4e9f2b598fdc..97f4d529ac0c 100644 --- a/tests/parser/legacyMedia.txt +++ b/tests/parser/legacyMedia.txt @@ -577,7 +577,7 @@ Image with link parameter, wgNoFollowDomainExceptions !! wikitext [[File:Foobar.jpg|link=http://example.com/]] !! config -wgNoFollowDomainExceptions="example.com" +wgNoFollowDomainExceptions=["example.com"] wgParserEnableLegacyMediaDOM=true !! html/php <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a> diff --git a/tests/parser/media.txt b/tests/parser/media.txt index e27b0ae67e88..21ac90b758e8 100644 --- a/tests/parser/media.txt +++ b/tests/parser/media.txt @@ -637,7 +637,7 @@ Image with link parameter, wgNoFollowDomainExceptions !! wikitext [[File:Foobar.jpg|link=http://example.com/]] !! config -wgNoFollowDomainExceptions="example.com" +wgNoFollowDomainExceptions=["example.com"] wgParserEnableLegacyMediaDOM=false !! html/php <p><span class="mw-default-size" typeof="mw:File"><a href="http://example.com/"><img src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a></span> |