* (bug 40352) fixDoubleRedirects.php should support interwiki redirects.
* (bug 9237) SpecialBrokenRedirect should not list interwiki redirects.
* (bug 34960) Drop unused fields rc_moved_to_ns and rc_moved_to_title from recentchanges table.
+* (bug 32951) Do not register internal externals with absolute protocol,
+ when server has relative protocol.
=== API changes in 1.21 ===
* (bug 35693) ApiQueryImageInfo now suppresses errors when unserializing metadata.
ApiQueryBase::addTitleInfo( $vals, $title );
}
if ( $fld_url ) {
- // We *could* run this through wfExpandUrl() but I think it's better to output the link verbatim, even if it's protocol-relative --Roan
- $vals['url'] = $row->el_to;
+ $to = $row->el_to;
+ // expand protocol-relative urls
+ if( $params['expandurl'] ) {
+ $to = wfExpandUrl( $to, PROTO_CANONICAL );
+ }
+ $vals['url'] = $to;
}
$fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $vals );
if ( !$fit ) {
ApiBase::PARAM_MIN => 1,
ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
- )
+ ),
+ 'expandurl' => false,
);
}
),
'query' => 'Search string without protocol. See [[Special:LinkSearch]]. Leave empty to list all external links',
'namespace' => 'The page namespace(s) to enumerate.',
- 'limit' => 'How many pages to return.'
+ 'limit' => 'How many pages to return.',
+ 'expandurl' => 'Expand protocol-relative urls with the canonical protocol',
);
if ( $wgMiserMode ) {
break;
}
$entry = array();
- // We *could* run this through wfExpandUrl() but I think it's better to output the link verbatim, even if it's protocol-relative --Roan
- ApiResult::setContent( $entry, $row->el_to );
+ $to = $row->el_to;
+ // expand protocol-relative urls
+ if( $params['expandurl'] ) {
+ $to = wfExpandUrl( $to, PROTO_CANONICAL );
+ }
+ ApiResult::setContent( $entry, $to );
$fit = $this->addPageSubItem( $row->el_from, $entry );
if ( !$fit ) {
$this->setContinueEnumParameter( 'offset', $offset + $count - 1 );
ApiBase::PARAM_DFLT => '',
),
'query' => null,
+ 'expandurl' => false,
);
}
"Leave both this and {$p}query empty to list all external links"
),
'query' => 'Search string without protocol. Useful for checking whether a certain page contains a certain external url',
+ 'expandurl' => 'Expand protocol-relative urls with the canonical protocol',
);
}
*/
protected function doGetFileContentsMulti( array $params ) {
$contents = array();
- wfSuppressWarnings();
foreach ( $this->doGetLocalReferenceMulti( $params ) as $path => $fsFile ) {
+ wfSuppressWarnings();
$contents[$path] = $fsFile ? file_get_contents( $fsFile->getPath() ) : false;
+ wfRestoreWarnings();
}
- wfRestoreWarnings();
return $contents;
}
return (bool)$this->mNewSection;
}
+ /**
+ * Checks, if a url is pointing to the own server
+ *
+ * @param $internal String the server to check against
+ * @param $url String the url to check
+ * @return bool
+ */
+ static function isLinkInternal( $internal, $url ) {
+ return (bool)preg_match( '/^' .
+ # If server is proto relative, check also for http/https links
+ ( substr( $internal, 0, 2 ) === '//' ? '(?:https?:)?' : '' ) .
+ preg_quote( $internal, '/' ) .
+ # check for query/path/anchor or end of link in each case
+ '(?:[\?\/\#]|$)/i',
+ $url
+ );
+ }
+
function addExternalLink( $url ) {
# We don't register links pointing to our own server, unless... :-)
global $wgServer, $wgRegisterInternalExternals;
- if( $wgRegisterInternalExternals or stripos($url,$wgServer.'/')!==0)
+
+ $registerExternalLink = true;
+ if( !$wgRegisterInternalExternals ) {
+ $registerExternalLink = !self::isLinkInternal( $wgServer, $url );
+ }
+ if( $registerExternalLink ) {
$this->mExternalLinks[$url] = 1;
+ }
}
/**
function getQueryInfo() {
$dbr = wfGetDB( DB_SLAVE );
$conds = array( 'rc_user > 0' ); // Users - no anons
- $conds[] = 'ipb_deleted IS NULL'; // don't show hidden names
+ if( !$this->getUser()->isAllowed( 'hideuser' ) ) {
+ $conds[] = 'ipb_deleted IS NULL OR ipb_deleted = 0'; // don't show hidden names
+ }
$conds[] = 'rc_log_type IS NULL OR rc_log_type != ' . $dbr->addQuotes( 'newusers' );
$conds[] = 'rc_timestamp >= ' . $dbr->addQuotes( $dbr->timestamp( wfTimestamp( TS_UNIX ) - $this->RCMaxAge*24*3600 ) );
'rc_user_text', // for Pager
'user_id',
'recentedits' => 'COUNT(*)',
- 'blocked' => 'MAX(ipb_user)'
+ 'ipb_deleted' => 'MAX(ipb_deleted)'
),
'options' => array(
'GROUP BY' => array( 'rc_user_text', 'user_id' ),
'user' => array( 'INNER JOIN', 'rc_user_text=user_name' ),
'ipblocks' => array( 'LEFT JOIN', array(
'user_id=ipb_user',
- 'ipb_auto' => 0,
- 'ipb_deleted' => 1
+ 'ipb_auto' => 0
)),
),
'conds' => $conds
$groups = $lang->commaList( $list );
$item = $lang->specialList( $ulinks, $groups );
+ if( $row->ipb_deleted ) {
+ $item = "<span class=\"deleted\">$item</span>";
+ }
$count = $this->msg( 'activeusers-count' )->numParams( $row->recentedits )
->params( $userName )->numParams( $this->RCMaxAge )->escaped();
- $blocked = $row->blocked ? ' ' . $this->msg( 'listusers-blocked', $userName )->escaped() : '';
+ $blocked = !is_null( $row->ipb_deleted ) ? ' ' . $this->msg( 'listusers-blocked', $userName )->escaped() : '';
return Html::rawElement( 'li', array(), "{$item} [{$count}]{$blocked}" );
}
$conds = array();
// Don't show hidden names
if( !$this->getUser()->isAllowed( 'hideuser' ) ) {
- $conds[] = 'ipb_deleted IS NULL';
+ $conds[] = 'ipb_deleted IS NULL OR ipb_deleted = 0';
}
$options = array();
'user_groups' => array( 'LEFT JOIN', 'user_id=ug_user' ),
'ipblocks' => array( 'LEFT JOIN', array(
'user_id=ipb_user',
- 'ipb_deleted' => 1,
'ipb_auto' => 0
)),
),
$created = $this->msg( 'usercreated', $d, $t, $row->user_name )->escaped();
$created = ' ' . $this->msg( 'parentheses' )->rawParams( $created )->escaped();
}
+ $blocked = !is_null( $row->ipb_deleted ) ? ' ' . $this->msg( 'listusers-blocked', $userName )->escaped() : '';
wfRunHooks( 'SpecialListusersFormatRow', array( &$item, $row ) );
- return Html::rawElement( 'li', array(), "{$item}{$edits}{$created}" );
+ return Html::rawElement( 'li', array(), "{$item}{$edits}{$created}{$blocked}" );
}
function doBatchLookups() {
</pre>
!!end
+###
+### Parsoid-centric tests for testing RT edge cases
+### around comments and white-space inside pre blocks
+###
+
+!!test
+1a. Pre and Comments
+!!input
+ a
+<!--a-->
+c
+!!result
+<pre>a
+</pre>
+<p>c
+</p>
+!!end
+
+!!test
+1b. Pre and Comments
+!!input
+ a
+ <!--a-->
+c
+!!result
+<pre>a
+</pre>
+<p>c
+</p>
+!!end
+
+!!test
+1c. Pre and Comments
+!!input
+<!--a--> a
+
+ <!--a--> a
+!!result
+<pre> a
+</pre>
+<pre> a
+</pre>
+!!end
+
###
### Definition lists
###
--- /dev/null
+<?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 ) );
+ }
+}