summaryrefslogtreecommitdiff
path: root/vendor/oojs/oojs-ui/php/Tag.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2015-12-17 09:15:42 +0100
committerPierre Schmitz <pierre@archlinux.de>2015-12-17 09:44:51 +0100
commita1789ddde42033f1b05cc4929491214ee6e79383 (patch)
tree63615735c4ddffaaabf2428946bb26f90899f7bf /vendor/oojs/oojs-ui/php/Tag.php
parent9e06a62f265e3a2aaabecc598d4bc617e06fa32d (diff)
Update to MediaWiki 1.26.0
Diffstat (limited to 'vendor/oojs/oojs-ui/php/Tag.php')
-rw-r--r--vendor/oojs/oojs-ui/php/Tag.php20
1 files changed, 12 insertions, 8 deletions
diff --git a/vendor/oojs/oojs-ui/php/Tag.php b/vendor/oojs/oojs-ui/php/Tag.php
index da8c2bfa..e5fa9df6 100644
--- a/vendor/oojs/oojs-ui/php/Tag.php
+++ b/vendor/oojs/oojs-ui/php/Tag.php
@@ -4,7 +4,7 @@ namespace OOUI;
class Tag {
- /* Members */
+ /* Properties */
/**
* Tag name for this instance.
@@ -296,23 +296,27 @@ class Tag {
// reasons to ever use 'javascript:' URLs anyway.
$protocolWhitelist = array(
// Sourced from MediaWiki's $wgUrlProtocols
+ // Keep in sync with OO.ui.isSafeUrl
'bitcoin', 'ftp', 'ftps', 'geo', 'git', 'gopher', 'http', 'https', 'irc', 'ircs',
'magnet', 'mailto', 'mms', 'news', 'nntp', 'redis', 'sftp', 'sip', 'sips', 'sms', 'ssh',
'svn', 'tel', 'telnet', 'urn', 'worldwind', 'xmpp',
+ '(protocol-relative)', '(relative)',
);
// Protocol-relative URLs are handled really badly by parse_url()
if ( substr( $value, 0, 2 ) === '//' ) {
- $url = "http:$value";
+ $scheme = '(protocol-relative)';
} else {
- $url = $value;
+ // Must suppress warnings when the value is not a valid URL. parse_url() returns false then.
+ \MediaWiki\suppressWarnings();
+ $scheme = parse_url( $value, PHP_URL_SCHEME );
+ \MediaWiki\restoreWarnings();
+ if ( $scheme === null || ( !$scheme && substr( $value, 0, 1 ) === '/' ) ) {
+ $scheme = '(relative)';
+ }
}
- // Must suppress warnings when the value is not a valid URL. parse_url() returns false then.
- // @codingStandardsIgnoreStart
- $scheme = @parse_url( $url, PHP_URL_SCHEME );
- // @codingStandardsIgnoreEnd
- if ( !( $scheme === null || in_array( strtolower( $scheme ), $protocolWhitelist ) ) ) {
+ if ( !in_array( strtolower( $scheme ), $protocolWhitelist ) ) {
throw new Exception( "Potentially unsafe '$key' attribute value. " .
"Scheme: '$scheme'; value: '$value'." );
}