Dr0ptp4kt has uploaded a new change for review.
https://gerrit.wikimedia.org/r/90466
Change subject: Add interstitial to all appropriate footer links. Fixes bug
55748.
......................................................................
Add interstitial to all appropriate footer links. Fixes bug 55748.
* Currently, the first qualifying link on a footer line gets rewritten.
* This patch rewrites every qualifying link per footer line.
Change-Id: I767584b135888fd0af90f75db4e0653df6d01586
---
M includes/PageRenderingHooks.php
1 file changed, 19 insertions(+), 14 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ZeroRatedMobileAccess
refs/changes/66/90466/1
diff --git a/includes/PageRenderingHooks.php b/includes/PageRenderingHooks.php
index e400928..44c7f7c 100644
--- a/includes/PageRenderingHooks.php
+++ b/includes/PageRenderingHooks.php
@@ -880,20 +880,25 @@
*/
private function addWarning( BaseTemplate $template, $templateValName )
{
$link = $template->get( $templateValName );
- if ( preg_match( '/href=([\'"])(.*?)\1/', $link, $match ) ) {
- $href = $match[2];
- $ch0 = substr( $href, 0, 1 );
- $ch1 = substr( $href, 1, 1 );
- // Local links start with either '#...', '?...' or
'/...', but not '//...'
- if ( $ch0 !== '#' && $ch0 !== '?' && ( $ch0 !== '/' ||
$ch1 === '/' ) ) {
- $link = str_replace(
- $href,
- $this->makeRedirect( $href ),
- $link
- );
- $template->set( $templateValName, $link );
- }
- }
+ $self = $this;
+ $link = preg_replace_callback( '/href=([\'"])(.*?)\1/',
+ function ( $matches ) use ( $self ) {
+ $quoteChar = $matches[1];
+ $a = "href=" . $quoteChar;
+ $b = $quoteChar;
+ $href = $matches[2];
+ $ch0 = substr( $href, 0, 1 );
+ $ch1 = substr( $href, 1, 1 );
+ // Local links start with either '#...', '?...'
or '/...', but not '//...'
+ if ( $ch0 !== '#' && $ch0 !== '?' && ( $ch0 !==
'/' || $ch1 === '/' ) ) {
+ return $a . $self->makeRedirect( $href
) . $b ;
+ } else {
+ return $matches[0];
+ }
+ },
+ $link
+ );
+ $template->set( $templateValName, $link );
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/90466
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I767584b135888fd0af90f75db4e0653df6d01586
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ZeroRatedMobileAccess
Gerrit-Branch: master
Gerrit-Owner: Dr0ptp4kt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits