jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/359791 )
Change subject: Improve documentation for wfParseUrl ...................................................................... Improve documentation for wfParseUrl Change-Id: I84ef76d2e3b026ed38e02a82245b559324950ede --- M includes/GlobalFunctions.php 1 file changed, 16 insertions(+), 2 deletions(-) Approvals: BryanDavis: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index c6ccf31..f7978c5 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -811,10 +811,24 @@ * 1) Does not raise warnings on bad URLs (just returns false). * 2) Handles protocols that don't use :// (e.g., mailto: and news:, as well as * protocol-relative URLs) correctly. - * 3) Adds a "delimiter" element to the array, either '://', ':' or '//' (see (2)). + * 3) Adds a "delimiter" element to the array (see (2)). + * 4) Verifies that the protocol is on the $wgUrlProtocols whitelist. + * 5) Rejects some invalid URLs that parse_url doesn't, e.g. the empty string or URLs starting with + * a line feed character. * * @param string $url A URL to parse - * @return string[]|bool Bits of the URL in an associative array, per PHP docs, false on failure + * @return string[]|bool Bits of the URL in an associative array, or false on failure. + * Possible fields: + * - scheme: URI scheme (protocol), e.g. 'http', 'mailto'. Lowercase, always present, but can + * be an empty string for protocol-relative URLs. + * - delimiter: either '://', ':' or '//'. Always present. + * - host: domain name / IP. Always present, but could be an empty string, e.g. for file: URLs. + * - user: user name, e.g. for HTTP Basic auth URLs such as http://user:[email protected]/ + * Missing when there is no username. + * - pass: password, same as above. + * - path: path including the leading /. Will be missing when empty (e.g. 'http://example.com') + * - query: query string (as a string; see wfCgiToArray() for parsing it), can be missing. + * - fragment: the part after #, can be missing. */ function wfParseUrl( $url ) { global $wgUrlProtocols; // Allow all protocols defined in DefaultSettings/LocalSettings.php -- To view, visit https://gerrit.wikimedia.org/r/359791 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I84ef76d2e3b026ed38e02a82245b559324950ede Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Gergő Tisza <[email protected]> Gerrit-Reviewer: Anomie <[email protected]> Gerrit-Reviewer: BryanDavis <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
