Remove support for $wgWellFormedXml=false
tl;dr: Having unnessary complexity in security critical code is bad.
* Extra options add extra complexity and maintenance burden
** Thus we should only have one html output mode. well formed = false
was already vetoed in T52040, so lets go with WellFormed=true.
* Options which are used by very few people tend to get tested less
* Escaping is an area of code where we should be very conservative
* Having escaping rules depend on making assumptions about which
characters various browsers consider "whitespace" is scary
* $wgWellFormedXml=false has had a negative security impact in the
past (Usually not directly its fault, but has made other bugs
more exploitable)
* Saving a couple bytes (even less bytes after gzip taken into
account) is really not worth it in this context (imho).
Change-Id: I5c922e0980d3f9eb39adb5bb5833e158afda42ed
This commit is contained in:
parent
50a3e5625a
commit
ee4d5c6eed
10 changed files with 136 additions and 241 deletions
|
|
@ -3130,24 +3130,6 @@ $wgHTMLFormAllowTableFormat = true;
|
||||||
*/
|
*/
|
||||||
$wgUseMediaWikiUIEverywhere = false;
|
$wgUseMediaWikiUIEverywhere = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* Should we try to make our HTML output well-formed XML? If set to false,
|
|
||||||
* output will be a few bytes shorter, and the HTML will arguably be more
|
|
||||||
* readable. If set to true, life will be much easier for the authors of
|
|
||||||
* screen-scraping bots, and the HTML will arguably be more readable.
|
|
||||||
*
|
|
||||||
* Setting this to false may omit quotation marks on some attributes, omit
|
|
||||||
* slashes from some self-closing tags, omit some ending tags, etc., where
|
|
||||||
* permitted by HTML5. Setting it to true will not guarantee that all pages
|
|
||||||
* will be well-formed, although non-well-formed pages should be rare and it's
|
|
||||||
* a bug if you find one. Conversely, setting it to false doesn't mean that
|
|
||||||
* all XML-y constructs will be omitted, just that they might be.
|
|
||||||
*
|
|
||||||
* Because of compatibility with screen-scraping bots, and because it's
|
|
||||||
* controversial, this is currently left to true by default.
|
|
||||||
*/
|
|
||||||
$wgWellFormedXml = true;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Permit other namespaces in addition to the w3.org default.
|
* Permit other namespaces in addition to the w3.org default.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,6 @@
|
||||||
*
|
*
|
||||||
* $wgMimeType: If this is set to an xml MIME type then output should be
|
* $wgMimeType: If this is set to an xml MIME type then output should be
|
||||||
* valid XHTML5.
|
* valid XHTML5.
|
||||||
* $wgWellFormedXml: If this is set to true, then all output should be
|
|
||||||
* well-formed XML (quotes on attributes, self-closing tags, etc.).
|
|
||||||
*
|
*
|
||||||
* This class is meant to be confined to utility functions that are called from
|
* This class is meant to be confined to utility functions that are called from
|
||||||
* trusted code paths. It does not do enforcement of policy like not allowing
|
* trusted code paths. It does not do enforcement of policy like not allowing
|
||||||
|
|
@ -199,8 +197,7 @@ class Html {
|
||||||
* This is quite similar to Xml::tags(), but it implements some useful
|
* This is quite similar to Xml::tags(), but it implements some useful
|
||||||
* HTML-specific logic. For instance, there is no $allowShortTag
|
* HTML-specific logic. For instance, there is no $allowShortTag
|
||||||
* parameter: the closing tag is magically omitted if $element has an empty
|
* parameter: the closing tag is magically omitted if $element has an empty
|
||||||
* content model. If $wgWellFormedXml is false, then a few bytes will be
|
* content model.
|
||||||
* shaved off the HTML output as well.
|
|
||||||
*
|
*
|
||||||
* @param string $element The element's name, e.g., 'a'
|
* @param string $element The element's name, e.g., 'a'
|
||||||
* @param array $attribs Associative array of attributes, e.g., array(
|
* @param array $attribs Associative array of attributes, e.g., array(
|
||||||
|
|
@ -211,14 +208,10 @@ class Html {
|
||||||
* @return string Raw HTML
|
* @return string Raw HTML
|
||||||
*/
|
*/
|
||||||
public static function rawElement( $element, $attribs = [], $contents = '' ) {
|
public static function rawElement( $element, $attribs = [], $contents = '' ) {
|
||||||
global $wgWellFormedXml;
|
|
||||||
$start = self::openElement( $element, $attribs );
|
$start = self::openElement( $element, $attribs );
|
||||||
if ( in_array( $element, self::$voidElements ) ) {
|
if ( in_array( $element, self::$voidElements ) ) {
|
||||||
if ( $wgWellFormedXml ) {
|
// Silly XML.
|
||||||
// Silly XML.
|
return substr( $start, 0, -1 ) . '/>';
|
||||||
return substr( $start, 0, -1 ) . '/>';
|
|
||||||
}
|
|
||||||
return $start;
|
|
||||||
} else {
|
} else {
|
||||||
return "$start$contents" . self::closeElement( $element );
|
return "$start$contents" . self::closeElement( $element );
|
||||||
}
|
}
|
||||||
|
|
@ -443,8 +436,6 @@ class Html {
|
||||||
* 'http://www.mediawiki.org/' ) becomes something like
|
* 'http://www.mediawiki.org/' ) becomes something like
|
||||||
* ' href="http://www.mediawiki.org"'. Again, this is like
|
* ' href="http://www.mediawiki.org"'. Again, this is like
|
||||||
* Xml::expandAttributes(), but it implements some HTML-specific logic.
|
* Xml::expandAttributes(), but it implements some HTML-specific logic.
|
||||||
* For instance, it will omit quotation marks if $wgWellFormedXml is false,
|
|
||||||
* and will treat boolean attributes specially.
|
|
||||||
*
|
*
|
||||||
* Attributes that can contain space-separated lists ('class', 'accesskey' and 'rel') array
|
* Attributes that can contain space-separated lists ('class', 'accesskey' and 'rel') array
|
||||||
* values are allowed as well, which will automagically be normalized
|
* values are allowed as well, which will automagically be normalized
|
||||||
|
|
@ -479,8 +470,6 @@ class Html {
|
||||||
* (starting with a space if at least one attribute is output)
|
* (starting with a space if at least one attribute is output)
|
||||||
*/
|
*/
|
||||||
public static function expandAttributes( array $attribs ) {
|
public static function expandAttributes( array $attribs ) {
|
||||||
global $wgWellFormedXml;
|
|
||||||
|
|
||||||
$ret = '';
|
$ret = '';
|
||||||
foreach ( $attribs as $key => $value ) {
|
foreach ( $attribs as $key => $value ) {
|
||||||
// Support intuitive array( 'checked' => true/false ) form
|
// Support intuitive array( 'checked' => true/false ) form
|
||||||
|
|
@ -564,31 +553,10 @@ class Html {
|
||||||
throw new MWException( "HTML attribute $key can not contain a list of values" );
|
throw new MWException( "HTML attribute $key can not contain a list of values" );
|
||||||
}
|
}
|
||||||
|
|
||||||
// See the "Attributes" section in the HTML syntax part of HTML5,
|
$quote = '"';
|
||||||
// 9.1.2.3 as of 2009-08-10. Most attributes can have quotation
|
|
||||||
// marks omitted, but not all. (Although a literal " is not
|
|
||||||
// permitted, we don't check for that, since it will be escaped
|
|
||||||
// anyway.)
|
|
||||||
|
|
||||||
// See also research done on further characters that need to be
|
|
||||||
// escaped: http://code.google.com/p/html5lib/issues/detail?id=93
|
|
||||||
$badChars = "\\x00- '=<>`/\x{00a0}\x{1680}\x{180e}\x{180F}\x{2000}\x{2001}"
|
|
||||||
. "\x{2002}\x{2003}\x{2004}\x{2005}\x{2006}\x{2007}\x{2008}\x{2009}"
|
|
||||||
. "\x{200A}\x{2028}\x{2029}\x{202F}\x{205F}\x{3000}";
|
|
||||||
if ( $wgWellFormedXml || $value === '' || preg_match( "![$badChars]!u", $value ) ) {
|
|
||||||
$quote = '"';
|
|
||||||
} else {
|
|
||||||
$quote = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( in_array( $key, self::$boolAttribs ) ) {
|
if ( in_array( $key, self::$boolAttribs ) ) {
|
||||||
// In HTML5, we can leave the value empty. If we don't need
|
$ret .= " $key=\"\"";
|
||||||
// well-formed XML, we can omit the = entirely.
|
|
||||||
if ( !$wgWellFormedXml ) {
|
|
||||||
$ret .= " $key";
|
|
||||||
} else {
|
|
||||||
$ret .= " $key=\"\"";
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Apparently we need to entity-encode \n, \r, \t, although the
|
// Apparently we need to entity-encode \n, \r, \t, although the
|
||||||
// spec doesn't mention that. Since we're doing strtr() anyway,
|
// spec doesn't mention that. Since we're doing strtr() anyway,
|
||||||
|
|
@ -599,22 +567,18 @@ class Html {
|
||||||
// don't because we're stubborn and like our marginal savings on
|
// don't because we're stubborn and like our marginal savings on
|
||||||
// byte size from not having to encode unnecessary quotes.
|
// byte size from not having to encode unnecessary quotes.
|
||||||
// The only difference between this transform and the one by
|
// The only difference between this transform and the one by
|
||||||
// Sanitizer::encodeAttribute() is '<' is only encoded here if
|
// Sanitizer::encodeAttribute() is ' is not encoded.
|
||||||
// $wgWellFormedXml is set, and ' is not encoded.
|
|
||||||
$map = [
|
$map = [
|
||||||
'&' => '&',
|
'&' => '&',
|
||||||
'"' => '"',
|
'"' => '"',
|
||||||
'>' => '>',
|
'>' => '>',
|
||||||
|
// '<' allegedly allowed per spec
|
||||||
|
// but breaks some tools if not escaped.
|
||||||
|
"<" => '<',
|
||||||
"\n" => ' ',
|
"\n" => ' ',
|
||||||
"\r" => ' ',
|
"\r" => ' ',
|
||||||
"\t" => '	'
|
"\t" => '	'
|
||||||
];
|
];
|
||||||
if ( $wgWellFormedXml ) {
|
|
||||||
// This is allowed per spec: <http://www.w3.org/TR/xml/#NT-AttValue>
|
|
||||||
// But reportedly it breaks some XML tools?
|
|
||||||
// @todo FIXME: Is this really true?
|
|
||||||
$map['<'] = '<';
|
|
||||||
}
|
|
||||||
$ret .= " $key=$quote" . strtr( $value, $map ) . $quote;
|
$ret .= " $key=$quote" . strtr( $value, $map ) . $quote;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -631,11 +595,9 @@ class Html {
|
||||||
* @return string Raw HTML
|
* @return string Raw HTML
|
||||||
*/
|
*/
|
||||||
public static function inlineScript( $contents ) {
|
public static function inlineScript( $contents ) {
|
||||||
global $wgWellFormedXml;
|
|
||||||
|
|
||||||
$attrs = [];
|
$attrs = [];
|
||||||
|
|
||||||
if ( $wgWellFormedXml && preg_match( '/[<&]/', $contents ) ) {
|
if ( preg_match( '/[<&]/', $contents ) ) {
|
||||||
$contents = "/*<![CDATA[*/$contents/*]]>*/";
|
$contents = "/*<![CDATA[*/$contents/*]]>*/";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -665,9 +627,7 @@ class Html {
|
||||||
* @return string Raw HTML
|
* @return string Raw HTML
|
||||||
*/
|
*/
|
||||||
public static function inlineStyle( $contents, $media = 'all' ) {
|
public static function inlineStyle( $contents, $media = 'all' ) {
|
||||||
global $wgWellFormedXml;
|
if ( preg_match( '/[<&]/', $contents ) ) {
|
||||||
|
|
||||||
if ( $wgWellFormedXml && preg_match( '/[<&]/', $contents ) ) {
|
|
||||||
$contents = "/*<![CDATA[*/$contents/*]]>*/";
|
$contents = "/*<![CDATA[*/$contents/*]]>*/";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -914,7 +914,6 @@ class ParserTest {
|
||||||
'wgExperimentalHtmlIds' => false,
|
'wgExperimentalHtmlIds' => false,
|
||||||
'wgExternalLinkTarget' => false,
|
'wgExternalLinkTarget' => false,
|
||||||
'wgHtml5' => true,
|
'wgHtml5' => true,
|
||||||
'wgWellFormedXml' => true,
|
|
||||||
'wgAdaptiveMessageCache' => true,
|
'wgAdaptiveMessageCache' => true,
|
||||||
'wgDisableLangConversion' => false,
|
'wgDisableLangConversion' => false,
|
||||||
'wgDisableTitleConversion' => false,
|
'wgDisableTitleConversion' => false,
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ class HtmlTest extends MediaWikiTestCase {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->setMwGlobals( [
|
$this->setMwGlobals( [
|
||||||
'wgWellFormedXml' => false,
|
|
||||||
'wgUseMediaWikiUIEverywhere' => false,
|
'wgUseMediaWikiUIEverywhere' => false,
|
||||||
] );
|
] );
|
||||||
|
|
||||||
|
|
@ -45,7 +44,7 @@ class HtmlTest extends MediaWikiTestCase {
|
||||||
*/
|
*/
|
||||||
public function testElementBasics() {
|
public function testElementBasics() {
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'<img>',
|
'<img/>',
|
||||||
Html::element( 'img', null, '' ),
|
Html::element( 'img', null, '' ),
|
||||||
'No close tag for short-tag elements'
|
'No close tag for short-tag elements'
|
||||||
);
|
);
|
||||||
|
|
@ -62,12 +61,10 @@ class HtmlTest extends MediaWikiTestCase {
|
||||||
'Close tag for empty element (array, string)'
|
'Close tag for empty element (array, string)'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->setMwGlobals( 'wgWellFormedXml', true );
|
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'<img/>',
|
'<img/>',
|
||||||
Html::element( 'img', null, '' ),
|
Html::element( 'img', null, '' ),
|
||||||
'Self-closing tag for short-tag elements (wgWellFormedXml = true)'
|
'Self-closing tag for short-tag elements'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -134,22 +131,20 @@ class HtmlTest extends MediaWikiTestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
' selected',
|
' selected=""',
|
||||||
Html::expandAttributes( [ 'selected' => true ] ),
|
Html::expandAttributes( [ 'selected' => true ] ),
|
||||||
'Boolean attributes have no value when value is true'
|
'Boolean attributes have no value when value is true'
|
||||||
);
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
' selected',
|
' selected=""',
|
||||||
Html::expandAttributes( [ 'selected' ] ),
|
Html::expandAttributes( [ 'selected' ] ),
|
||||||
'Boolean attributes have no value when value is true (passed as numerical array)'
|
'Boolean attributes have no value when value is true (passed as numerical array)'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->setMwGlobals( 'wgWellFormedXml', true );
|
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
' selected=""',
|
' selected=""',
|
||||||
Html::expandAttributes( [ 'selected' => true ] ),
|
Html::expandAttributes( [ 'selected' => true ] ),
|
||||||
'Boolean attributes have empty string value when value is true (wgWellFormedXml)'
|
'Boolean attributes have empty string value when value is true'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -158,12 +153,12 @@ class HtmlTest extends MediaWikiTestCase {
|
||||||
*/
|
*/
|
||||||
public function testExpandAttributesForNumbers() {
|
public function testExpandAttributesForNumbers() {
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
' value=1',
|
' value="1"',
|
||||||
Html::expandAttributes( [ 'value' => 1 ] ),
|
Html::expandAttributes( [ 'value' => 1 ] ),
|
||||||
'Integer value is cast to a string'
|
'Integer value is cast to a string'
|
||||||
);
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
' value=1.1',
|
' value="1.1"',
|
||||||
Html::expandAttributes( [ 'value' => 1.1 ] ),
|
Html::expandAttributes( [ 'value' => 1.1 ] ),
|
||||||
'Float value is cast to a string'
|
'Float value is cast to a string'
|
||||||
);
|
);
|
||||||
|
|
@ -174,7 +169,7 @@ class HtmlTest extends MediaWikiTestCase {
|
||||||
*/
|
*/
|
||||||
public function testExpandAttributesForObjects() {
|
public function testExpandAttributesForObjects() {
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
' value=stringValue',
|
' value="stringValue"',
|
||||||
Html::expandAttributes( [ 'value' => new HtmlTestValue() ] ),
|
Html::expandAttributes( [ 'value' => new HtmlTestValue() ] ),
|
||||||
'Object value is converted to a string'
|
'Object value is converted to a string'
|
||||||
);
|
);
|
||||||
|
|
@ -193,43 +188,21 @@ class HtmlTest extends MediaWikiTestCase {
|
||||||
'Empty string is always quoted'
|
'Empty string is always quoted'
|
||||||
);
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
' key=value',
|
' key="value"',
|
||||||
Html::expandAttributes( [ 'key' => 'value' ] ),
|
Html::expandAttributes( [ 'key' => 'value' ] ),
|
||||||
'Simple string value needs no quotes'
|
'Simple string value needs no quotes'
|
||||||
);
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
' one=1',
|
' one="1"',
|
||||||
Html::expandAttributes( [ 'one' => 1 ] ),
|
Html::expandAttributes( [ 'one' => 1 ] ),
|
||||||
'Number 1 value needs no quotes'
|
'Number 1 value needs no quotes'
|
||||||
);
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
' zero=0',
|
' zero="0"',
|
||||||
Html::expandAttributes( [ 'zero' => 0 ] ),
|
Html::expandAttributes( [ 'zero' => 0 ] ),
|
||||||
'Number 0 value needs no quotes'
|
'Number 0 value needs no quotes'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->setMwGlobals( 'wgWellFormedXml', true );
|
|
||||||
|
|
||||||
$this->assertEquals(
|
|
||||||
' empty_string=""',
|
|
||||||
Html::expandAttributes( [ 'empty_string' => '' ] ),
|
|
||||||
'Attribute values are always quoted (wgWellFormedXml): Empty string'
|
|
||||||
);
|
|
||||||
$this->assertEquals(
|
|
||||||
' key="value"',
|
|
||||||
Html::expandAttributes( [ 'key' => 'value' ] ),
|
|
||||||
'Attribute values are always quoted (wgWellFormedXml): Simple string'
|
|
||||||
);
|
|
||||||
$this->assertEquals(
|
|
||||||
' one="1"',
|
|
||||||
Html::expandAttributes( [ 'one' => 1 ] ),
|
|
||||||
'Attribute values are always quoted (wgWellFormedXml): Number 1'
|
|
||||||
);
|
|
||||||
$this->assertEquals(
|
|
||||||
' zero="0"',
|
|
||||||
Html::expandAttributes( [ 'zero' => 0 ] ),
|
|
||||||
'Attribute values are always quoted (wgWellFormedXml): Number 0'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -346,48 +319,48 @@ class HtmlTest extends MediaWikiTestCase {
|
||||||
*/
|
*/
|
||||||
public function testNamespaceSelector() {
|
public function testNamespaceSelector() {
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'<select id=namespace name=namespace>' . "\n" .
|
'<select id="namespace" name="namespace">' . "\n" .
|
||||||
'<option value=0>(Main)</option>' . "\n" .
|
'<option value="0">(Main)</option>' . "\n" .
|
||||||
'<option value=1>Talk</option>' . "\n" .
|
'<option value="1">Talk</option>' . "\n" .
|
||||||
'<option value=2>User</option>' . "\n" .
|
'<option value="2">User</option>' . "\n" .
|
||||||
'<option value=3>User talk</option>' . "\n" .
|
'<option value="3">User talk</option>' . "\n" .
|
||||||
'<option value=4>MyWiki</option>' . "\n" .
|
'<option value="4">MyWiki</option>' . "\n" .
|
||||||
'<option value=5>MyWiki Talk</option>' . "\n" .
|
'<option value="5">MyWiki Talk</option>' . "\n" .
|
||||||
'<option value=6>File</option>' . "\n" .
|
'<option value="6">File</option>' . "\n" .
|
||||||
'<option value=7>File talk</option>' . "\n" .
|
'<option value="7">File talk</option>' . "\n" .
|
||||||
'<option value=8>MediaWiki</option>' . "\n" .
|
'<option value="8">MediaWiki</option>' . "\n" .
|
||||||
'<option value=9>MediaWiki talk</option>' . "\n" .
|
'<option value="9">MediaWiki talk</option>' . "\n" .
|
||||||
'<option value=10>Template</option>' . "\n" .
|
'<option value="10">Template</option>' . "\n" .
|
||||||
'<option value=11>Template talk</option>' . "\n" .
|
'<option value="11">Template talk</option>' . "\n" .
|
||||||
'<option value=14>Category</option>' . "\n" .
|
'<option value="14">Category</option>' . "\n" .
|
||||||
'<option value=15>Category talk</option>' . "\n" .
|
'<option value="15">Category talk</option>' . "\n" .
|
||||||
'<option value=100>Custom</option>' . "\n" .
|
'<option value="100">Custom</option>' . "\n" .
|
||||||
'<option value=101>Custom talk</option>' . "\n" .
|
'<option value="101">Custom talk</option>' . "\n" .
|
||||||
'</select>',
|
'</select>',
|
||||||
Html::namespaceSelector(),
|
Html::namespaceSelector(),
|
||||||
'Basic namespace selector without custom options'
|
'Basic namespace selector without custom options'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'<label for=mw-test-namespace>Select a namespace:</label> ' .
|
'<label for="mw-test-namespace">Select a namespace:</label> ' .
|
||||||
'<select id=mw-test-namespace name=wpNamespace>' . "\n" .
|
'<select id="mw-test-namespace" name="wpNamespace">' . "\n" .
|
||||||
'<option value=all>all</option>' . "\n" .
|
'<option value="all">all</option>' . "\n" .
|
||||||
'<option value=0>(Main)</option>' . "\n" .
|
'<option value="0">(Main)</option>' . "\n" .
|
||||||
'<option value=1>Talk</option>' . "\n" .
|
'<option value="1">Talk</option>' . "\n" .
|
||||||
'<option value=2 selected>User</option>' . "\n" .
|
'<option value="2" selected="">User</option>' . "\n" .
|
||||||
'<option value=3>User talk</option>' . "\n" .
|
'<option value="3">User talk</option>' . "\n" .
|
||||||
'<option value=4>MyWiki</option>' . "\n" .
|
'<option value="4">MyWiki</option>' . "\n" .
|
||||||
'<option value=5>MyWiki Talk</option>' . "\n" .
|
'<option value="5">MyWiki Talk</option>' . "\n" .
|
||||||
'<option value=6>File</option>' . "\n" .
|
'<option value="6">File</option>' . "\n" .
|
||||||
'<option value=7>File talk</option>' . "\n" .
|
'<option value="7">File talk</option>' . "\n" .
|
||||||
'<option value=8>MediaWiki</option>' . "\n" .
|
'<option value="8">MediaWiki</option>' . "\n" .
|
||||||
'<option value=9>MediaWiki talk</option>' . "\n" .
|
'<option value="9">MediaWiki talk</option>' . "\n" .
|
||||||
'<option value=10>Template</option>' . "\n" .
|
'<option value="10">Template</option>' . "\n" .
|
||||||
'<option value=11>Template talk</option>' . "\n" .
|
'<option value="11">Template talk</option>' . "\n" .
|
||||||
'<option value=14>Category</option>' . "\n" .
|
'<option value="14">Category</option>' . "\n" .
|
||||||
'<option value=15>Category talk</option>' . "\n" .
|
'<option value="15">Category talk</option>' . "\n" .
|
||||||
'<option value=100>Custom</option>' . "\n" .
|
'<option value="100">Custom</option>' . "\n" .
|
||||||
'<option value=101>Custom talk</option>' . "\n" .
|
'<option value="101">Custom talk</option>' . "\n" .
|
||||||
'</select>',
|
'</select>',
|
||||||
Html::namespaceSelector(
|
Html::namespaceSelector(
|
||||||
[ 'selected' => '2', 'all' => 'all', 'label' => 'Select a namespace:' ],
|
[ 'selected' => '2', 'all' => 'all', 'label' => 'Select a namespace:' ],
|
||||||
|
|
@ -397,24 +370,24 @@ class HtmlTest extends MediaWikiTestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'<label for=namespace>Select a namespace:</label> ' .
|
'<label for="namespace">Select a namespace:</label> ' .
|
||||||
'<select id=namespace name=namespace>' . "\n" .
|
'<select id="namespace" name="namespace">' . "\n" .
|
||||||
'<option value=0>(Main)</option>' . "\n" .
|
'<option value="0">(Main)</option>' . "\n" .
|
||||||
'<option value=1>Talk</option>' . "\n" .
|
'<option value="1">Talk</option>' . "\n" .
|
||||||
'<option value=2>User</option>' . "\n" .
|
'<option value="2">User</option>' . "\n" .
|
||||||
'<option value=3>User talk</option>' . "\n" .
|
'<option value="3">User talk</option>' . "\n" .
|
||||||
'<option value=4>MyWiki</option>' . "\n" .
|
'<option value="4">MyWiki</option>' . "\n" .
|
||||||
'<option value=5>MyWiki Talk</option>' . "\n" .
|
'<option value="5">MyWiki Talk</option>' . "\n" .
|
||||||
'<option value=6>File</option>' . "\n" .
|
'<option value="6">File</option>' . "\n" .
|
||||||
'<option value=7>File talk</option>' . "\n" .
|
'<option value="7">File talk</option>' . "\n" .
|
||||||
'<option value=8>MediaWiki</option>' . "\n" .
|
'<option value="8">MediaWiki</option>' . "\n" .
|
||||||
'<option value=9>MediaWiki talk</option>' . "\n" .
|
'<option value="9">MediaWiki talk</option>' . "\n" .
|
||||||
'<option value=10>Template</option>' . "\n" .
|
'<option value="10">Template</option>' . "\n" .
|
||||||
'<option value=11>Template talk</option>' . "\n" .
|
'<option value="11">Template talk</option>' . "\n" .
|
||||||
'<option value=14>Category</option>' . "\n" .
|
'<option value="14">Category</option>' . "\n" .
|
||||||
'<option value=15>Category talk</option>' . "\n" .
|
'<option value="15">Category talk</option>' . "\n" .
|
||||||
'<option value=100>Custom</option>' . "\n" .
|
'<option value="100">Custom</option>' . "\n" .
|
||||||
'<option value=101>Custom talk</option>' . "\n" .
|
'<option value="101">Custom talk</option>' . "\n" .
|
||||||
'</select>',
|
'</select>',
|
||||||
Html::namespaceSelector(
|
Html::namespaceSelector(
|
||||||
[ 'label' => 'Select a namespace:' ]
|
[ 'label' => 'Select a namespace:' ]
|
||||||
|
|
@ -425,18 +398,18 @@ class HtmlTest extends MediaWikiTestCase {
|
||||||
|
|
||||||
public function testCanFilterOutNamespaces() {
|
public function testCanFilterOutNamespaces() {
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'<select id=namespace name=namespace>' . "\n" .
|
'<select id="namespace" name="namespace">' . "\n" .
|
||||||
'<option value=2>User</option>' . "\n" .
|
'<option value="2">User</option>' . "\n" .
|
||||||
'<option value=4>MyWiki</option>' . "\n" .
|
'<option value="4">MyWiki</option>' . "\n" .
|
||||||
'<option value=5>MyWiki Talk</option>' . "\n" .
|
'<option value="5">MyWiki Talk</option>' . "\n" .
|
||||||
'<option value=6>File</option>' . "\n" .
|
'<option value="6">File</option>' . "\n" .
|
||||||
'<option value=7>File talk</option>' . "\n" .
|
'<option value="7">File talk</option>' . "\n" .
|
||||||
'<option value=8>MediaWiki</option>' . "\n" .
|
'<option value="8">MediaWiki</option>' . "\n" .
|
||||||
'<option value=9>MediaWiki talk</option>' . "\n" .
|
'<option value="9">MediaWiki talk</option>' . "\n" .
|
||||||
'<option value=10>Template</option>' . "\n" .
|
'<option value="10">Template</option>' . "\n" .
|
||||||
'<option value=11>Template talk</option>' . "\n" .
|
'<option value="11">Template talk</option>' . "\n" .
|
||||||
'<option value=14>Category</option>' . "\n" .
|
'<option value="14">Category</option>' . "\n" .
|
||||||
'<option value=15>Category talk</option>' . "\n" .
|
'<option value="15">Category talk</option>' . "\n" .
|
||||||
'</select>',
|
'</select>',
|
||||||
Html::namespaceSelector(
|
Html::namespaceSelector(
|
||||||
[ 'exclude' => [ 0, 1, 3, 100, 101 ] ]
|
[ 'exclude' => [ 0, 1, 3, 100, 101 ] ]
|
||||||
|
|
@ -447,23 +420,23 @@ class HtmlTest extends MediaWikiTestCase {
|
||||||
|
|
||||||
public function testCanDisableANamespaces() {
|
public function testCanDisableANamespaces() {
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'<select id=namespace name=namespace>' . "\n" .
|
'<select id="namespace" name="namespace">' . "\n" .
|
||||||
'<option disabled value=0>(Main)</option>' . "\n" .
|
'<option disabled="" value="0">(Main)</option>' . "\n" .
|
||||||
'<option disabled value=1>Talk</option>' . "\n" .
|
'<option disabled="" value="1">Talk</option>' . "\n" .
|
||||||
'<option disabled value=2>User</option>' . "\n" .
|
'<option disabled="" value="2">User</option>' . "\n" .
|
||||||
'<option disabled value=3>User talk</option>' . "\n" .
|
'<option disabled="" value="3">User talk</option>' . "\n" .
|
||||||
'<option disabled value=4>MyWiki</option>' . "\n" .
|
'<option disabled="" value="4">MyWiki</option>' . "\n" .
|
||||||
'<option value=5>MyWiki Talk</option>' . "\n" .
|
'<option value="5">MyWiki Talk</option>' . "\n" .
|
||||||
'<option value=6>File</option>' . "\n" .
|
'<option value="6">File</option>' . "\n" .
|
||||||
'<option value=7>File talk</option>' . "\n" .
|
'<option value="7">File talk</option>' . "\n" .
|
||||||
'<option value=8>MediaWiki</option>' . "\n" .
|
'<option value="8">MediaWiki</option>' . "\n" .
|
||||||
'<option value=9>MediaWiki talk</option>' . "\n" .
|
'<option value="9">MediaWiki talk</option>' . "\n" .
|
||||||
'<option value=10>Template</option>' . "\n" .
|
'<option value="10">Template</option>' . "\n" .
|
||||||
'<option value=11>Template talk</option>' . "\n" .
|
'<option value="11">Template talk</option>' . "\n" .
|
||||||
'<option value=14>Category</option>' . "\n" .
|
'<option value="14">Category</option>' . "\n" .
|
||||||
'<option value=15>Category talk</option>' . "\n" .
|
'<option value="15">Category talk</option>' . "\n" .
|
||||||
'<option value=100>Custom</option>' . "\n" .
|
'<option value="100">Custom</option>' . "\n" .
|
||||||
'<option value=101>Custom talk</option>' . "\n" .
|
'<option value="101">Custom talk</option>' . "\n" .
|
||||||
'</select>',
|
'</select>',
|
||||||
Html::namespaceSelector( [
|
Html::namespaceSelector( [
|
||||||
'disable' => [ 0, 1, 2, 3, 4 ]
|
'disable' => [ 0, 1, 2, 3, 4 ]
|
||||||
|
|
@ -478,7 +451,7 @@ class HtmlTest extends MediaWikiTestCase {
|
||||||
*/
|
*/
|
||||||
public function testHtmlElementAcceptsNewHtml5TypesInHtml5Mode( $HTML5InputType ) {
|
public function testHtmlElementAcceptsNewHtml5TypesInHtml5Mode( $HTML5InputType ) {
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'<input type=' . $HTML5InputType . '>',
|
'<input type="' . $HTML5InputType . '"/>',
|
||||||
Html::element( 'input', [ 'type' => $HTML5InputType ] ),
|
Html::element( 'input', [ 'type' => $HTML5InputType ] ),
|
||||||
'In HTML5, Html::element() should accept type="' . $HTML5InputType . '"'
|
'In HTML5, Html::element() should accept type="' . $HTML5InputType . '"'
|
||||||
);
|
);
|
||||||
|
|
@ -528,14 +501,14 @@ class HtmlTest extends MediaWikiTestCase {
|
||||||
$cases = [];
|
$cases = [];
|
||||||
|
|
||||||
# ## Generic cases, match $attribDefault static array
|
# ## Generic cases, match $attribDefault static array
|
||||||
$cases[] = [ '<area>',
|
$cases[] = [ '<area/>',
|
||||||
'area', [ 'shape' => 'rect' ]
|
'area', [ 'shape' => 'rect' ]
|
||||||
];
|
];
|
||||||
|
|
||||||
$cases[] = [ '<button type=submit></button>',
|
$cases[] = [ '<button type="submit"></button>',
|
||||||
'button', [ 'formaction' => 'GET' ]
|
'button', [ 'formaction' => 'GET' ]
|
||||||
];
|
];
|
||||||
$cases[] = [ '<button type=submit></button>',
|
$cases[] = [ '<button type="submit"></button>',
|
||||||
'button', [ 'formenctype' => 'application/x-www-form-urlencoded' ]
|
'button', [ 'formenctype' => 'application/x-www-form-urlencoded' ]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -553,7 +526,7 @@ class HtmlTest extends MediaWikiTestCase {
|
||||||
'canvas', [ 'width' => 300 ]
|
'canvas', [ 'width' => 300 ]
|
||||||
];
|
];
|
||||||
|
|
||||||
$cases[] = [ '<command>',
|
$cases[] = [ '<command/>',
|
||||||
'command', [ 'type' => 'command' ]
|
'command', [ 'type' => 'command' ]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -567,18 +540,18 @@ class HtmlTest extends MediaWikiTestCase {
|
||||||
'form', [ 'enctype' => 'application/x-www-form-urlencoded' ]
|
'form', [ 'enctype' => 'application/x-www-form-urlencoded' ]
|
||||||
];
|
];
|
||||||
|
|
||||||
$cases[] = [ '<input>',
|
$cases[] = [ '<input/>',
|
||||||
'input', [ 'formaction' => 'GET' ]
|
'input', [ 'formaction' => 'GET' ]
|
||||||
];
|
];
|
||||||
$cases[] = [ '<input>',
|
$cases[] = [ '<input/>',
|
||||||
'input', [ 'type' => 'text' ]
|
'input', [ 'type' => 'text' ]
|
||||||
];
|
];
|
||||||
|
|
||||||
$cases[] = [ '<keygen>',
|
$cases[] = [ '<keygen/>',
|
||||||
'keygen', [ 'keytype' => 'rsa' ]
|
'keygen', [ 'keytype' => 'rsa' ]
|
||||||
];
|
];
|
||||||
|
|
||||||
$cases[] = [ '<link>',
|
$cases[] = [ '<link/>',
|
||||||
'link', [ 'media' => 'all' ]
|
'link', [ 'media' => 'all' ]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -604,44 +577,44 @@ class HtmlTest extends MediaWikiTestCase {
|
||||||
# ## SPECIFIC CASES
|
# ## SPECIFIC CASES
|
||||||
|
|
||||||
# <link type="text/css">
|
# <link type="text/css">
|
||||||
$cases[] = [ '<link>',
|
$cases[] = [ '<link/>',
|
||||||
'link', [ 'type' => 'text/css' ]
|
'link', [ 'type' => 'text/css' ]
|
||||||
];
|
];
|
||||||
|
|
||||||
# <input> specific handling
|
# <input> specific handling
|
||||||
$cases[] = [ '<input type=checkbox>',
|
$cases[] = [ '<input type="checkbox"/>',
|
||||||
'input', [ 'type' => 'checkbox', 'value' => 'on' ],
|
'input', [ 'type' => 'checkbox', 'value' => 'on' ],
|
||||||
'Default value "on" is stripped of checkboxes',
|
'Default value "on" is stripped of checkboxes',
|
||||||
];
|
];
|
||||||
$cases[] = [ '<input type=radio>',
|
$cases[] = [ '<input type="radio"/>',
|
||||||
'input', [ 'type' => 'radio', 'value' => 'on' ],
|
'input', [ 'type' => 'radio', 'value' => 'on' ],
|
||||||
'Default value "on" is stripped of radio buttons',
|
'Default value "on" is stripped of radio buttons',
|
||||||
];
|
];
|
||||||
$cases[] = [ '<input type=submit value=Submit>',
|
$cases[] = [ '<input type="submit" value="Submit"/>',
|
||||||
'input', [ 'type' => 'submit', 'value' => 'Submit' ],
|
'input', [ 'type' => 'submit', 'value' => 'Submit' ],
|
||||||
'Default value "Submit" is kept on submit buttons (for possible l10n issues)',
|
'Default value "Submit" is kept on submit buttons (for possible l10n issues)',
|
||||||
];
|
];
|
||||||
$cases[] = [ '<input type=color>',
|
$cases[] = [ '<input type="color"/>',
|
||||||
'input', [ 'type' => 'color', 'value' => '' ],
|
'input', [ 'type' => 'color', 'value' => '' ],
|
||||||
];
|
];
|
||||||
$cases[] = [ '<input type=range>',
|
$cases[] = [ '<input type="range"/>',
|
||||||
'input', [ 'type' => 'range', 'value' => '' ],
|
'input', [ 'type' => 'range', 'value' => '' ],
|
||||||
];
|
];
|
||||||
|
|
||||||
# <button> specific handling
|
# <button> specific handling
|
||||||
# see remarks on http://msdn.microsoft.com/en-us/library/ie/ms535211%28v=vs.85%29.aspx
|
# see remarks on http://msdn.microsoft.com/en-us/library/ie/ms535211%28v=vs.85%29.aspx
|
||||||
$cases[] = [ '<button type=submit></button>',
|
$cases[] = [ '<button type="submit"></button>',
|
||||||
'button', [ 'type' => 'submit' ],
|
'button', [ 'type' => 'submit' ],
|
||||||
'According to standard the default type is "submit". '
|
'According to standard the default type is "submit". '
|
||||||
. 'Depending on compatibility mode IE might use "button", instead.',
|
. 'Depending on compatibility mode IE might use "button", instead.',
|
||||||
];
|
];
|
||||||
|
|
||||||
# <select> specific handling
|
# <select> specific handling
|
||||||
$cases[] = [ '<select multiple></select>',
|
$cases[] = [ '<select multiple=""></select>',
|
||||||
'select', [ 'size' => '4', 'multiple' => true ],
|
'select', [ 'size' => '4', 'multiple' => true ],
|
||||||
];
|
];
|
||||||
# .. with numeric value
|
# .. with numeric value
|
||||||
$cases[] = [ '<select multiple></select>',
|
$cases[] = [ '<select multiple=""></select>',
|
||||||
'select', [ 'size' => 4, 'multiple' => true ],
|
'select', [ 'size' => 4, 'multiple' => true ],
|
||||||
];
|
];
|
||||||
$cases[] = [ '<select></select>',
|
$cases[] = [ '<select></select>',
|
||||||
|
|
@ -693,7 +666,7 @@ class HtmlTest extends MediaWikiTestCase {
|
||||||
'Blacklist form validation attributes.'
|
'Blacklist form validation attributes.'
|
||||||
);
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
' step=any',
|
' step="any"',
|
||||||
Html::expandAttributes(
|
Html::expandAttributes(
|
||||||
[
|
[
|
||||||
'min' => 1,
|
'min' => 1,
|
||||||
|
|
@ -709,12 +682,12 @@ class HtmlTest extends MediaWikiTestCase {
|
||||||
|
|
||||||
public function testWrapperInput() {
|
public function testWrapperInput() {
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'<input type=radio value=testval name=testname>',
|
'<input type="radio" value="testval" name="testname"/>',
|
||||||
Html::input( 'testname', 'testval', 'radio' ),
|
Html::input( 'testname', 'testval', 'radio' ),
|
||||||
'Input wrapper with type and value.'
|
'Input wrapper with type and value.'
|
||||||
);
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'<input name=testname>',
|
'<input name="testname"/>',
|
||||||
Html::input( 'testname' ),
|
Html::input( 'testname' ),
|
||||||
'Input wrapper with all default values.'
|
'Input wrapper with all default values.'
|
||||||
);
|
);
|
||||||
|
|
@ -722,17 +695,17 @@ class HtmlTest extends MediaWikiTestCase {
|
||||||
|
|
||||||
public function testWrapperCheck() {
|
public function testWrapperCheck() {
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'<input type=checkbox value=1 name=testname>',
|
'<input type="checkbox" value="1" name="testname"/>',
|
||||||
Html::check( 'testname' ),
|
Html::check( 'testname' ),
|
||||||
'Checkbox wrapper unchecked.'
|
'Checkbox wrapper unchecked.'
|
||||||
);
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'<input checked type=checkbox value=1 name=testname>',
|
'<input checked="" type="checkbox" value="1" name="testname"/>',
|
||||||
Html::check( 'testname', true ),
|
Html::check( 'testname', true ),
|
||||||
'Checkbox wrapper checked.'
|
'Checkbox wrapper checked.'
|
||||||
);
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'<input type=checkbox value=testval name=testname>',
|
'<input type="checkbox" value="testval" name="testname"/>',
|
||||||
Html::check( 'testname', false, [ 'value' => 'testval' ] ),
|
Html::check( 'testname', false, [ 'value' => 'testval' ] ),
|
||||||
'Checkbox wrapper with a value override.'
|
'Checkbox wrapper with a value override.'
|
||||||
);
|
);
|
||||||
|
|
@ -740,17 +713,17 @@ class HtmlTest extends MediaWikiTestCase {
|
||||||
|
|
||||||
public function testWrapperRadio() {
|
public function testWrapperRadio() {
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'<input type=radio value=1 name=testname>',
|
'<input type="radio" value="1" name="testname"/>',
|
||||||
Html::radio( 'testname' ),
|
Html::radio( 'testname' ),
|
||||||
'Radio wrapper unchecked.'
|
'Radio wrapper unchecked.'
|
||||||
);
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'<input checked type=radio value=1 name=testname>',
|
'<input checked="" type="radio" value="1" name="testname"/>',
|
||||||
Html::radio( 'testname', true ),
|
Html::radio( 'testname', true ),
|
||||||
'Radio wrapper checked.'
|
'Radio wrapper checked.'
|
||||||
);
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'<input type=radio value=testval name=testname>',
|
'<input type="radio" value="testval" name="testname"/>',
|
||||||
Html::radio( 'testname', false, [ 'value' => 'testval' ] ),
|
Html::radio( 'testname', false, [ 'value' => 'testval' ] ),
|
||||||
'Radio wrapper with a value override.'
|
'Radio wrapper with a value override.'
|
||||||
);
|
);
|
||||||
|
|
@ -758,7 +731,7 @@ class HtmlTest extends MediaWikiTestCase {
|
||||||
|
|
||||||
public function testWrapperLabel() {
|
public function testWrapperLabel() {
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'<label for=testid>testlabel</label>',
|
'<label for="testid">testlabel</label>',
|
||||||
Html::label( 'testlabel', 'testid' ),
|
Html::label( 'testlabel', 'testid' ),
|
||||||
'Label wrapper'
|
'Label wrapper'
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@ class LinkerTest extends MediaWikiLangTestCase {
|
||||||
public function testUserLink( $expected, $userId, $userName, $altUserName = false, $msg = '' ) {
|
public function testUserLink( $expected, $userId, $userName, $altUserName = false, $msg = '' ) {
|
||||||
$this->setMwGlobals( [
|
$this->setMwGlobals( [
|
||||||
'wgArticlePath' => '/wiki/$1',
|
'wgArticlePath' => '/wiki/$1',
|
||||||
'wgWellFormedXml' => true,
|
|
||||||
] );
|
] );
|
||||||
|
|
||||||
$this->assertEquals( $expected,
|
$this->assertEquals( $expected,
|
||||||
|
|
@ -112,7 +111,6 @@ class LinkerTest extends MediaWikiLangTestCase {
|
||||||
$this->setMwGlobals( [
|
$this->setMwGlobals( [
|
||||||
'wgScript' => '/wiki/index.php',
|
'wgScript' => '/wiki/index.php',
|
||||||
'wgArticlePath' => '/wiki/$1',
|
'wgArticlePath' => '/wiki/$1',
|
||||||
'wgWellFormedXml' => true,
|
|
||||||
'wgCapitalLinks' => true,
|
'wgCapitalLinks' => true,
|
||||||
'wgConf' => $conf,
|
'wgConf' => $conf,
|
||||||
] );
|
] );
|
||||||
|
|
@ -277,7 +275,6 @@ class LinkerTest extends MediaWikiLangTestCase {
|
||||||
$this->setMwGlobals( [
|
$this->setMwGlobals( [
|
||||||
'wgScript' => '/wiki/index.php',
|
'wgScript' => '/wiki/index.php',
|
||||||
'wgArticlePath' => '/wiki/$1',
|
'wgArticlePath' => '/wiki/$1',
|
||||||
'wgWellFormedXml' => true,
|
|
||||||
'wgCapitalLinks' => true,
|
'wgCapitalLinks' => true,
|
||||||
'wgConf' => $conf,
|
'wgConf' => $conf,
|
||||||
] );
|
] );
|
||||||
|
|
@ -367,7 +364,6 @@ class LinkerTest extends MediaWikiLangTestCase {
|
||||||
public function testLinkBeginHook( $callback, $expected ) {
|
public function testLinkBeginHook( $callback, $expected ) {
|
||||||
$this->setMwGlobals( [
|
$this->setMwGlobals( [
|
||||||
'wgArticlePath' => '/wiki/$1',
|
'wgArticlePath' => '/wiki/$1',
|
||||||
'wgWellFormedXml' => true,
|
|
||||||
'wgServer' => '//example.org',
|
'wgServer' => '//example.org',
|
||||||
'wgCanonicalServer' => 'http://example.org',
|
'wgCanonicalServer' => 'http://example.org',
|
||||||
'wgScriptPath' => '/w',
|
'wgScriptPath' => '/w',
|
||||||
|
|
@ -414,7 +410,6 @@ class LinkerTest extends MediaWikiLangTestCase {
|
||||||
public function testLinkEndHook( $callback, $expected ) {
|
public function testLinkEndHook( $callback, $expected ) {
|
||||||
$this->setMwGlobals( [
|
$this->setMwGlobals( [
|
||||||
'wgArticlePath' => '/wiki/$1',
|
'wgArticlePath' => '/wiki/$1',
|
||||||
'wgWellFormedXml' => true,
|
|
||||||
] );
|
] );
|
||||||
|
|
||||||
$this->setMwGlobals( 'wgHooks', [ 'LinkEnd' => [ $callback ] ] );
|
$this->setMwGlobals( 'wgHooks', [ 'LinkEnd' => [ $callback ] ] );
|
||||||
|
|
|
||||||
|
|
@ -149,14 +149,14 @@ class OutputPageTest extends MediaWikiTestCase {
|
||||||
[
|
[
|
||||||
// Don't condition wrap raw modules (like the startup module)
|
// Don't condition wrap raw modules (like the startup module)
|
||||||
[ 'test.raw', ResourceLoaderModule::TYPE_SCRIPTS ],
|
[ 'test.raw', ResourceLoaderModule::TYPE_SCRIPTS ],
|
||||||
'<script async src="http://127.0.0.1:8080/w/load.php?debug=false&lang=en&modules=test.raw&only=scripts&skin=fallback"></script>'
|
'<script async="" src="http://127.0.0.1:8080/w/load.php?debug=false&lang=en&modules=test.raw&only=scripts&skin=fallback"></script>'
|
||||||
],
|
],
|
||||||
// Load module styles only
|
// Load module styles only
|
||||||
// This also tests the order the modules are put into the url
|
// This also tests the order the modules are put into the url
|
||||||
[
|
[
|
||||||
[ [ 'test.baz', 'test.foo', 'test.bar' ], ResourceLoaderModule::TYPE_STYLES ],
|
[ [ 'test.baz', 'test.foo', 'test.bar' ], ResourceLoaderModule::TYPE_STYLES ],
|
||||||
|
|
||||||
'<link rel=stylesheet href="http://127.0.0.1:8080/w/load.php?debug=false&lang=en&modules=test.bar%2Cbaz%2Cfoo&only=styles&skin=fallback">'
|
'<link rel="stylesheet" href="http://127.0.0.1:8080/w/load.php?debug=false&lang=en&modules=test.bar%2Cbaz%2Cfoo&only=styles&skin=fallback"/>'
|
||||||
],
|
],
|
||||||
// Load private module (only=scripts)
|
// Load private module (only=scripts)
|
||||||
[
|
[
|
||||||
|
|
@ -181,7 +181,7 @@ class OutputPageTest extends MediaWikiTestCase {
|
||||||
// noscript group
|
// noscript group
|
||||||
[
|
[
|
||||||
[ 'test.noscript', ResourceLoaderModule::TYPE_STYLES ],
|
[ 'test.noscript', ResourceLoaderModule::TYPE_STYLES ],
|
||||||
'<noscript><link rel=stylesheet href="http://127.0.0.1:8080/w/load.php?debug=false&lang=en&modules=test.noscript&only=styles&skin=fallback"></noscript>'
|
'<noscript><link rel="stylesheet" href="http://127.0.0.1:8080/w/load.php?debug=false&lang=en&modules=test.noscript&only=styles&skin=fallback"/></noscript>'
|
||||||
],
|
],
|
||||||
// Load two modules in separate groups
|
// Load two modules in separate groups
|
||||||
[
|
[
|
||||||
|
|
@ -210,8 +210,6 @@ class OutputPageTest extends MediaWikiTestCase {
|
||||||
$this->setMwGlobals( [
|
$this->setMwGlobals( [
|
||||||
'wgResourceLoaderDebug' => false,
|
'wgResourceLoaderDebug' => false,
|
||||||
'wgLoadScript' => 'http://127.0.0.1:8080/w/load.php',
|
'wgLoadScript' => 'http://127.0.0.1:8080/w/load.php',
|
||||||
// Affects whether CDATA is inserted
|
|
||||||
'wgWellFormedXml' => false,
|
|
||||||
] );
|
] );
|
||||||
$class = new ReflectionClass( 'OutputPage' );
|
$class = new ReflectionClass( 'OutputPage' );
|
||||||
$method = $class->getMethod( 'makeResourceLoaderLink' );
|
$method = $class->getMethod( 'makeResourceLoaderLink' );
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,6 @@ class XmlSelectTest extends MediaWikiTestCase {
|
||||||
|
|
||||||
protected function setUp() {
|
protected function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->setMwGlobals( [
|
|
||||||
'wgWellFormedXml' => true,
|
|
||||||
] );
|
|
||||||
$this->select = new XmlSelect();
|
$this->select = new XmlSelect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@ class XmlTest extends MediaWikiTestCase {
|
||||||
|
|
||||||
$this->setMwGlobals( [
|
$this->setMwGlobals( [
|
||||||
'wgLang' => $langObj,
|
'wgLang' => $langObj,
|
||||||
'wgWellFormedXml' => true,
|
|
||||||
'wgUseMediaWikiUIEverywhere' => false,
|
'wgUseMediaWikiUIEverywhere' => false,
|
||||||
] );
|
] );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,6 @@
|
||||||
*/
|
*/
|
||||||
class JsonContentTest extends MediaWikiLangTestCase {
|
class JsonContentTest extends MediaWikiLangTestCase {
|
||||||
|
|
||||||
protected function setUp() {
|
|
||||||
parent::setUp();
|
|
||||||
|
|
||||||
$this->setMwGlobals( 'wgWellFormedXml', true );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function provideValidConstruction() {
|
public static function provideValidConstruction() {
|
||||||
return [
|
return [
|
||||||
[ 'foo', false, null ],
|
[ 'foo', false, null ],
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,6 @@ class NewParserTest extends MediaWikiTestCase {
|
||||||
$tmpGlobals['wgUseImageResize'] = true;
|
$tmpGlobals['wgUseImageResize'] = true;
|
||||||
$tmpGlobals['wgAllowExternalImages'] = true;
|
$tmpGlobals['wgAllowExternalImages'] = true;
|
||||||
$tmpGlobals['wgRawHtml'] = false;
|
$tmpGlobals['wgRawHtml'] = false;
|
||||||
$tmpGlobals['wgWellFormedXml'] = true;
|
|
||||||
$tmpGlobals['wgExperimentalHtmlIds'] = false;
|
$tmpGlobals['wgExperimentalHtmlIds'] = false;
|
||||||
$tmpGlobals['wgAdaptiveMessageCache'] = true;
|
$tmpGlobals['wgAdaptiveMessageCache'] = true;
|
||||||
$tmpGlobals['wgUseDatabaseMessages'] = true;
|
$tmpGlobals['wgUseDatabaseMessages'] = true;
|
||||||
|
|
@ -436,7 +435,6 @@ class NewParserTest extends MediaWikiTestCase {
|
||||||
'wgThumbLimits' => [ self::getOptionValue( 'thumbsize', $opts, 180 ) ],
|
'wgThumbLimits' => [ self::getOptionValue( 'thumbsize', $opts, 180 ) ],
|
||||||
'wgMaxTocLevel' => $maxtoclevel,
|
'wgMaxTocLevel' => $maxtoclevel,
|
||||||
'wgUseTeX' => isset( $opts['math'] ) || isset( $opts['texvc'] ),
|
'wgUseTeX' => isset( $opts['math'] ) || isset( $opts['texvc'] ),
|
||||||
'wgWellFormedXml' => true,
|
|
||||||
'wgMathDirectory' => $uploadDir . '/math',
|
'wgMathDirectory' => $uploadDir . '/math',
|
||||||
'wgDefaultLanguageVariant' => $variant,
|
'wgDefaultLanguageVariant' => $variant,
|
||||||
'wgLinkHolderBatchSize' => $linkHolderBatchSize,
|
'wgLinkHolderBatchSize' => $linkHolderBatchSize,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue