Skip to content

Commit

Permalink
Merge pull request #1531 from splitbrain/noopener
Browse files Browse the repository at this point in the history
add rel=noopener to links opening in new window
  • Loading branch information
splitbrain committed Apr 18, 2016
2 parents 8f70999 + bc3d225 commit 3faf777
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions inc/parser/xhtml.php
Expand Up @@ -938,10 +938,12 @@ function externallink($url, $name = null, $returnonly = false) {
$link['more'] = '';
$link['class'] = $class;
$link['url'] = $url;
$link['rel'] = '';

$link['name'] = $name;
$link['title'] = $this->_xmlEntities($url);
if($conf['relnofollow']) $link['more'] .= ' rel="nofollow"';
if($conf['relnofollow']) $link['rel'] .= ' nofollow';
if($conf['target']['extern']) $link['rel'] .= ' noopener';

//output formatted
if($returnonly) {
Expand Down Expand Up @@ -971,6 +973,7 @@ function interwikilink($match, $name = null, $wikiName, $wikiUri, $returnonly =
$link['suf'] = '';
$link['more'] = '';
$link['name'] = $this->_getLinkTitle($name, $wikiUri, $isImage);
$link['rel'] = '';

//get interwiki URL
$exists = null;
Expand All @@ -992,9 +995,10 @@ function interwikilink($match, $name = null, $wikiName, $wikiUri, $returnonly =
$link['class'] .= ' wikilink1';
} else {
$link['class'] .= ' wikilink2';
$link['rel'] = 'nofollow';
$link['rel'] .= ' nofollow';
}
}
if($conf['target']['interwiki']) $link['rel'] .= ' noopener';

$link['url'] = $url;
$link['title'] = htmlspecialchars($link['url']);
Expand Down Expand Up @@ -1448,7 +1452,7 @@ function _formatLink($link) {
if(!empty($link['target'])) $ret .= ' target="'.$link['target'].'"';
if(!empty($link['title'])) $ret .= ' title="'.$link['title'].'"';
if(!empty($link['style'])) $ret .= ' style="'.$link['style'].'"';
if(!empty($link['rel'])) $ret .= ' rel="'.$link['rel'].'"';
if(!empty($link['rel'])) $ret .= ' rel="'.trim($link['rel']).'"';
if(!empty($link['more'])) $ret .= ' '.$link['more'];
$ret .= '>';
$ret .= $link['name'];
Expand Down Expand Up @@ -1682,6 +1686,7 @@ function _getMediaLinkConf($src, $title, $align, $width, $height, $cache, $rende
$link['suf'] = '';
$link['more'] = '';
$link['target'] = $conf['target']['media'];
if($conf['target']['media']) $link['rel'] = 'noopener';
$link['title'] = $this->_xmlEntities($src);
$link['name'] = $this->_media($src, $title, $align, $width, $height, $cache, $render);

Expand Down

0 comments on commit 3faf777

Please sign in to comment.