Setting $wgRegisterInternalExternals = false for proto server should not store the http/https links in externallinks table Also fix detection of own links for links with query or anchor or nothing new also detected: //localhost //localhost?query //localhost#anchor already detected: //localhost/path Change-Id: Idd03d309cc3b71728a8cbea460efa12b10348d64
38 lines
1.5 KiB
PHP
38 lines
1.5 KiB
PHP
<?php
|
|
|
|
class ParserOutputTest extends MediaWikiTestCase {
|
|
|
|
function dataIsLinkInternal() {
|
|
return array(
|
|
// Different domains
|
|
array( false, 'http://example.org', 'http://mediawiki.org' ),
|
|
// Same domains
|
|
array( true, 'http://example.org', 'http://example.org' ),
|
|
array( true, 'https://example.org', 'https://example.org' ),
|
|
array( true, '//example.org', '//example.org' ),
|
|
// Same domain different cases
|
|
array( true, 'http://example.org', 'http://EXAMPLE.ORG' ),
|
|
// Paths, queries, and fragments are not relevant
|
|
array( true, 'http://example.org', 'http://example.org/wiki/Main_Page' ),
|
|
array( true, 'http://example.org', 'http://example.org?my=query' ),
|
|
array( true, 'http://example.org', 'http://example.org#its-a-fragment' ),
|
|
// Different protocols
|
|
array( false, 'http://example.org', 'https://example.org' ),
|
|
array( false, 'https://example.org', 'http://example.org' ),
|
|
// Protocol relative servers always match http and https links
|
|
array( true, '//example.org', 'http://example.org' ),
|
|
array( true, '//example.org', 'https://example.org' ),
|
|
// But they don't match strange things like this
|
|
array( false, '//example.org', 'irc://example.org' ),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Test to make sure ParserOutput::isLinkInternal behaves properly
|
|
* @dataProvider dataIsLinkInternal
|
|
*/
|
|
function testIsLinkInternal( $shouldMatch, $server, $url ) {
|
|
|
|
$this->assertEquals( $shouldMatch, ParserOutput::isLinkInternal( $server, $url ) );
|
|
}
|
|
}
|