--- includes/actions/HistoryAction.php 2014-12-17 21:11:53.000000000 +0100 +++ includes/actions/HistoryAction.php 2015-03-22 15:16:39.157038654 +0100 @@ -663,7 +663,15 @@ } # Text following the character difference is added just before running hooks - $s2 = Linker::revComment( $rev, false, true ); + /*op-patch|TS|2014-09-30|HaloACL|Protected properties|start*/ + // + global $haclgProtectProperties; + $s2 = ''; + if (!$haclgProtectProperties) { + // The comment for an article might reveal values of protected properties + $s2 = Linker::revComment( $rev, false, true ); + } + /*op-patch|TS|2014-09-30|end*/ if ( $notificationtimestamp && ( $row->rev_timestamp >= $notificationtimestamp ) ) { $s2 .= ' ' . $this->msg( 'updatedmarker' )->escaped() . ''; --- includes/diff/TableDiffFormatter.php 2014-12-17 21:11:53.000000000 +0100 +++ includes/diff/TableDiffFormatter.php 2015-03-22 15:16:39.797041836 +0100 @@ -96,7 +96,16 @@ * @return string */ protected function addedLine( $line ) { - return $this->wrapLine( '+', 'diff-addedline', $line ); + global $haclgProtectProperties; + if (!$haclgProtectProperties || !defined('SMW_VERSION') || !strpos($line, "::") ) { + // Properties are not protected or no properties in line - everything can be processed + return $this->wrapLine( '+++', 'diff-addedline', $line ); + } else { // properties in text + $regexpattern = '/::[^\]]*/'; + $regexreplace = '::Property value removed by HaloACL'; + $line2 = preg_replace($regexpattern, $regexreplace, $line); + return $this->wrapLine( '+', 'diff-addedline', $line2 ); + } } /** @@ -107,7 +116,16 @@ * @return string */ protected function deletedLine( $line ) { - return $this->wrapLine( '−', 'diff-deletedline', $line ); + global $haclgProtectProperties; + if (!$haclgProtectProperties || !defined('SMW_VERSION') || !strpos($line, "::") ) { + // Properties are not protected or no properties in line - everything can be processed + return $this->wrapLine( '-', 'diff-addedline', $line ); + } else { // properties in text + $regexpattern = '/::[^\]]*/'; + $regexreplace = '::Property value removed by HaloACL'; + $line2 = preg_replace($regexpattern, $regexreplace, $line); + return $this->wrapLine( '-', 'diff-addedline', $line2 ); + } } /** @@ -118,7 +136,16 @@ * @return string */ protected function contextLine( $line ) { - return $this->wrapLine( ' ', 'diff-context', $line ); + global $haclgProtectProperties; + if (!$haclgProtectProperties || !defined('SMW_VERSION') || !strpos($line, "::") ) { + // Properties are not protected or no properties in line - everything can be processed + return $this->wrapLine( ' ', 'diff-addedline', $line ); + } else { // properties in text + $regexpattern = '/::[^\]]*/'; + $regexreplace = '::Property value removed by HaloACL'; + $line2 = preg_replace($regexpattern, $regexreplace, $line); + return $this->wrapLine( ' ', 'diff-addedline', $line2 ); + } } /** --- includes/.htaccess 2014-12-17 21:11:53.000000000 +0100 +++ includes/.htaccess 1970-01-01 01:00:00.000000000 +0100 @@ -1 +0,0 @@ -Deny from all --- includes/logging/LogEventsList.php 2014-12-17 21:11:53.000000000 +0100 +++ includes/logging/LogEventsList.php 2015-03-22 15:16:43.481060100 +0100 @@ -308,6 +308,13 @@ $formatter->setContext( $this->getContext() ); $formatter->setShowUserToolLinks( !( $this->flags & self::NO_EXTRA_USER_LINKS ) ); +/*op-patch|start*/ + $title = $entry->getTarget(); + if (!$title->userCanReadEx()) { + return ''; + } +/*op-patch|end*/ + $time = htmlspecialchars( $this->getLanguage()->userTimeAndDate( $entry->getTimestamp(), $this->getUser() ) ); --- includes/specialpage/QueryPage.php 2014-12-17 21:11:53.000000000 +0100 +++ includes/specialpage/QueryPage.php 2015-03-22 15:16:44.925067258 +0100 @@ -600,6 +600,21 @@ // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed for ( $i = 0; $i < $num && $row = $res->fetchObject(); $i++ ) { // @codingStandardsIgnoreEnd + /*op-patch|TS|2014-09-30|HaloACL|SafeTitle|start*/ + // See http://dmwiki.ontoprise.com/dmwiki/index.php/SafeTitle + $title = null; + if (isset($row->namespace) && isset($row->title)) { + $title = Title::makeTitleSafe( $row->namespace, $row->title ); + } else if (isset($row->id)) { + $title = Title::newFromID($row->id); + } else if (isset($row->type) && $row->type === 'Templates' + && isset($row->title)) { + $title = Title::makeTitleSafe(NS_TEMPLATE, $row->title); + } + if ($title && !$title->userCanReadEx()) { + continue; + } + /*op-patch|TS|2014-09-30|end*/ $line = $this->formatResult( $skin, $row ); if ( $line ) { $attr = ( isset( $row->usepatrol ) && $row->usepatrol && $row->patrolled == 0 ) --- includes/specials/SpecialAllPages.php 2014-12-17 21:11:53.000000000 +0100 +++ includes/specials/SpecialAllPages.php 2015-03-22 15:16:45.089068079 +0100 @@ -216,6 +216,12 @@ $out = Xml::openElement( 'ul', array( 'class' => 'mw-allpages-chunk' ) ); while ( ( $n < $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) { $t = Title::newFromRow( $s ); + /*op-patch|TS|2014-09-30|HaloACL|SafeTitle|start*/ + // See http://dmwiki.ontoprise.com:8888/dmwiki/index.php/SafeTitle + if ($t && !$t->userCanReadEx()) { + continue; + } + /*op-patch|TS|2014-09-30|end*/ if ( $t ) { $out .= '
Search result deleted by HaloACL
'; + } + + } + } +/*op-patch|TS|2014-09-30|end*/ $result = $matches->next(); } $out .= "\n"; --- includes/specials/SpecialWatchlist.php 2014-12-17 21:11:53.000000000 +0100 +++ includes/specials/SpecialWatchlist.php 2015-03-22 15:16:45.045067856 +0100 @@ -359,6 +359,12 @@ foreach ( $rows as $obj ) { # Make RC entry $rc = RecentChange::newFromRow( $obj ); + /*op-patch|TS|2014-09-30|HaloACL|SafeTitle|start*/ + // See http://dmwiki.ontoprise.com:8888/dmwiki/index.php/SafeTitle + if (!$rc->getTitle()->userCanReadEx()) { + continue; + } + /*op-patch|TS|2014-09-30|end*/ $rc->counter = $counter++; if ( $this->getConfig()->get( 'ShowUpdatedMarker' ) ) { --- includes/specials/SpecialWhatlinkshere.php 2014-12-17 21:11:53.000000000 +0100 +++ includes/specials/SpecialWhatlinkshere.php 2015-03-22 15:16:45.101068132 +0100 @@ -272,6 +272,12 @@ $out->addHTML( $this->listStart( $level ) ); foreach ( $rows as $row ) { $nt = Title::makeTitle( $row->page_namespace, $row->page_title ); +/*op-patch|TS|2014-09-30|HaloACL|SafeTitle|start*/ +// See http://dmwiki.ontoprise.com:8888/dmwiki/index.php/SafeTitle + if (!$nt->userCanReadEx()) { + continue; + } +/*op-patch|TS|2014-09-30|end*/ if ( $row->rd_from && $level < 2 ) { $out->addHTML( $this->listItem( $row, $nt, $target, true ) ); --- includes/Title.php 2014-12-17 21:11:53.000000000 +0100 +++ includes/Title.php 2015-03-22 15:16:45.257068906 +0100 @@ -227,9 +227,15 @@ public static function newFromDBkey( $key ) { $t = new Title(); $t->mDbkeyform = $key; - if ( $t->secureAndSplit() ) { - return $t; - } else { + if( $t->secureAndSplit() ) { + /*op-patch|TS|2014-09-30|HaloACL|SafeTitle|start*/ + // See http://dmwiki.ontoprise.com:8888/dmwiki/index.php/SafeTitle + return $t->checkAccessControl(); + } + /*op-patch|TS|2014-09-30|end*/ + //Replaced by patch return $t; + + else { return null; } } @@ -291,7 +297,11 @@ if ( $defaultNamespace == NS_MAIN ) { $cache->set( $text, $t ); } - return $t; +/*op-patch|TS|2014-09-30|HaloACL|SafeTitle|start*/ +// See http://dmwiki.ontoprise.com:8888/dmwiki/index.php/SafeTitle + return $t->checkAccessControl(); +/*op-patch|TS|2014-09-30|end*/ +// Preplaced by patch return $t; } else { return null; } @@ -324,7 +334,11 @@ $t->mDbkeyform = str_replace( ' ', '_', $url ); if ( $t->secureAndSplit() ) { - return $t; +/*op-patch|TS|2014-09-30|HaloACL|SafeTitle|start*/ +// See http://dmwiki.ontoprise.com:8888/dmwiki/index.php/SafeTitle + return $t->checkAccessControl(); +/*op-patch|TS|2014-09-30|end*/ +// Preplaced by patch return $t; } else { return null; } @@ -483,7 +497,12 @@ $t->mUrlform = wfUrlencode( $t->mDbkeyform ); $t->mTextform = str_replace( '_', ' ', $title ); $t->mContentModel = false; # initialized lazily in getContentModel() +/*op-patch|TS|2014-09-30|HaloACL|SafeTitle|start*/ +// See http://dmwiki.ontoprise.com:8888/dmwiki/index.php/SafeTitle + $t = $t->checkAccessControl(); return $t; ++/*op-patch|TS|2014-09-30|end*/ ++// Preplaced by patch return $t; } /** @@ -505,7 +524,11 @@ $t = new Title(); $t->mDbkeyform = Title::makeName( $ns, $title, $fragment, $interwiki ); if ( $t->secureAndSplit() ) { - return $t; +/*op-patch|TS|2014-09-30|HaloACL|SafeTitle|start*/ +// See http://dmwiki.ontoprise.com:8888/dmwiki/index.php/SafeTitle + return $t->checkAccessControl(); +/*op-patch|TS|2014-09-30|end*/ +// Preplaced by patch return $t; } else { return null; } @@ -1175,6 +1198,29 @@ return $result; } + /*op-patch|TS|2012-02-24|HaloACL|HaloACLMemcache|start*/ + // See http://dmwiki.ontoprise.com/index.php/HaloACLMemcache + public function userCanRead() { + if (!defined('HACL_HALOACL_VERSION')) { + //HaloACL is disabled + return $this->userCanReadOrig(); + } + + global $wgUser; + $hmc = HACLMemcache::getInstance(); + $allowed = $hmc->retrievePermission($wgUser, $this, 'read'); + if ($allowed === -1) { + $allowed = $this->userCanReadOrig(); + $hmc->storePermission($wgUser, $this, 'read', $allowed); + } + return $allowed; + } + + public function userCanReadOrig() { + wfDeprecated( __METHOD__, '1.19' ); + return $this->userCan( 'read' ); + } + /** * Is this the mainpage? * @note Title::newFromText seems to be sufficiently optimized by the title @@ -1511,6 +1557,23 @@ return implode( '/', $parts ); } +/*op-patch|TS|2012-02-24|HaloACL|HaloACLMemcache|start*/ + public function userCanOrig($action, $doExpensiveQueries = true) { + if (!defined('HACL_HALOACL_VERSION')) { + //HaloACL is disabled + return $this->userCanOrig($action, $doExpensiveQueries); + } + + global $wgUser; + $hmc = HACLMemcache::getInstance(); + $allowed = $hmc->retrievePermission($wgUser, $this, $action); + if ($allowed === -1) { + $allowed = $this->userCanOrig($action, $doExpensiveQueries); + $hmc->storePermission($wgUser, $this, $action, $allowed); + } + return $allowed; + } + /** * Get the base page name title, i.e. the part before the subpage name * @@ -2364,7 +2427,7 @@ # If it's a special page, ditch the subpage bit and check again $name = $this->getDBkey(); list( $name, /* $subpage */ ) = SpecialPageFactory::resolveAlias( $name ); - if ( $name ) { + if ( !is_null($name) ) { $pure = SpecialPage::getTitleFor( $name )->getPrefixedText(); if ( in_array( $pure, $wgWhitelistRead, true ) ) { $whitelisted = true; @@ -2384,6 +2447,8 @@ } } + wfRunHooks( 'userCan', array( &$this, &$user, $action, &$whitelisted ) ); + if ( !$whitelisted ) { # If the title is not whitelisted, give extensions a chance to do so... wfRunHooks( 'TitleReadWhitelist', array( $this, $user, &$whitelisted ) ); @@ -4338,6 +4403,99 @@ return $exists; } +/*op-patch|TS|2014-09-30|HaloACL|SafeTitle|start*/ + + + /** + * This function is called from the patches for HaloACL for secure listings + * (e.g. Spcecial:AllPages). It checks, whether the current user is allowed + * to read the article for this title object. For normal pages this is + * evaluate in the method