diff --git a/_test/tests/inc/tar.test.php b/_test/tests/inc/tar.test.php index 28e709cc39a22246b1c6450b52b538ee0e8ca8b7..50664cfc31ff7bcdcc91345eb4e3966a3053e0fb 100644 --- a/_test/tests/inc/tar.test.php +++ b/_test/tests/inc/tar.test.php @@ -11,7 +11,8 @@ class Tar_TestCase extends DokuWikiTest { public function test_createdynamic() { $tar = new Tar(); - $dir = dirname(__FILE__).'/tar'; + $dir = dirname(__FILE__).'/tar'; + $tdir = ltrim($dir,'/'); $tar->create(); $tar->AddFile("$dir/testdata1.txt"); @@ -24,11 +25,11 @@ class Tar_TestCase extends DokuWikiTest { $this->assertTrue(strpos($data, 'testcontent2') !== false, 'Content in TAR'); $this->assertTrue(strpos($data, 'testcontent3') !== false, 'Content in TAR'); - $this->assertTrue(strpos($data, "$dir/testdata1.txt") !== false, 'Path in TAR'); + $this->assertTrue(strpos($data, "$tdir/testdata1.txt") !== false, 'Path in TAR'); $this->assertTrue(strpos($data, 'noway/testdata2.txt') !== false, 'Path in TAR'); $this->assertTrue(strpos($data, 'another/testdata3.txt') !== false, 'Path in TAR'); - $this->assertTrue(strpos($data, "$dir/foobar/testdata2.txt") === false, 'Path not in TAR'); + $this->assertTrue(strpos($data, "$tdir/foobar/testdata2.txt") === false, 'Path not in TAR'); $this->assertTrue(strpos($data, "foobar") === false, 'Path not in TAR'); } @@ -42,6 +43,7 @@ class Tar_TestCase extends DokuWikiTest { $tar = new Tar(); $dir = dirname(__FILE__).'/tar'; + $tdir = ltrim($dir,'/'); $tmp = tempnam(sys_get_temp_dir(), 'dwtartest'); $tar->create($tmp, Tar::COMPRESS_NONE); @@ -57,11 +59,11 @@ class Tar_TestCase extends DokuWikiTest { $this->assertTrue(strpos($data, 'testcontent2') !== false, 'Content in TAR'); $this->assertTrue(strpos($data, 'testcontent3') !== false, 'Content in TAR'); - $this->assertTrue(strpos($data, "$dir/testdata1.txt") !== false, 'Path in TAR'); + $this->assertTrue(strpos($data, "$tdir/testdata1.txt") !== false, 'Path in TAR'); $this->assertTrue(strpos($data, 'noway/testdata2.txt') !== false, 'Path in TAR'); $this->assertTrue(strpos($data, 'another/testdata3.txt') !== false, 'Path in TAR'); - $this->assertTrue(strpos($data, "$dir/foobar/testdata2.txt") === false, 'Path not in TAR'); + $this->assertTrue(strpos($data, "$tdir/foobar/testdata2.txt") === false, 'Path not in TAR'); $this->assertTrue(strpos($data, "foobar") === false, 'Path not in TAR'); @unlink($tmp); diff --git a/inc/html.php b/inc/html.php index 1bd1a74e48339cf84a66191b5efc1c2b6904cf91..614cf172c1c80e48a69bea7b7f0ff3acdfa27194 100644 --- a/inc/html.php +++ b/inc/html.php @@ -854,12 +854,17 @@ function html_index($ns){ * @author Andreas Gohr <andi@splitbrain.org> */ function html_list_index($item){ - global $ID; + global $ID, $conf; + + // prevent searchbots needlessly following links + $nofollow = ($ID != $conf['start'] || $conf['sitemap']) ? ' rel="nofollow"' : ''; + $ret = ''; $base = ':'.$item['id']; $base = substr($base,strrpos($base,':')+1); if($item['type']=='d'){ - $ret .= '<a href="'.wl($ID,'idx='.rawurlencode($item['id'])).'" title="' . $item['id'] . '" class="idx_dir"><strong>'; + // FS#2766, no need for search bots to follow namespace links in the index + $ret .= '<a href="'.wl($ID,'idx='.rawurlencode($item['id'])).'" title="' . $item['id'] . '" class="idx_dir"' . $nofollow . '><strong>'; $ret .= $base; $ret .= '</strong></a>'; }else{ diff --git a/inc/template.php b/inc/template.php index 66cbbe471a7b390fecc70b56f66a8e7318799b80..bb5f2cd53a90b150a34ea6a21794493d241326a2 100644 --- a/inc/template.php +++ b/inc/template.php @@ -541,6 +541,7 @@ function tpl_actionlink($type, $pre = '', $suf = '', $inner = '', $return = fals * @var string $accesskey * @var string $id * @var string $method + * @var bool $nofollow * @var array $params */ extract($data); @@ -555,10 +556,11 @@ function tpl_actionlink($type, $pre = '', $suf = '', $inner = '', $return = fals $akey = 'accesskey="'.$accesskey.'" '; $addTitle = ' ['.strtoupper($accesskey).']'; } + $rel = $nofollow ? 'rel="nofollow" ' : ''; $out = tpl_link( $linktarget, $pre.(($inner) ? $inner : $caption).$suf, 'class="action '.$type.'" '. - $akey.'rel="nofollow" '. + $akey.$rel. 'title="'.hsc($caption).$addTitle.'"', 1 ); } @@ -595,6 +597,7 @@ function tpl_get_action($type) { global $INFO; global $REV; global $ACT; + global $conf; // check disabled actions and fix the badly named ones if($type == 'history') $type = 'revisions'; @@ -604,6 +607,7 @@ function tpl_get_action($type) { $id = $ID; $method = 'get'; $params = array('do' => $type); + $nofollow = true; switch($type) { case 'edit': // most complicated type - we need to decide on current action @@ -641,6 +645,10 @@ function tpl_get_action($type) { break; case 'index': $accesskey = 'x'; + // allow searchbots to get to the sitemap from the homepage (when dokuwiki isn't providing a sitemap.xml) + if ($conf['start'] == $ID && !$conf['sitemap']) { + $nofollow = false; + } break; case 'top': $accesskey = 't'; @@ -711,7 +719,7 @@ function tpl_get_action($type) { return '[unknown %s type]'; break; } - return compact('accesskey', 'type', 'id', 'method', 'params'); + return compact('accesskey', 'type', 'id', 'method', 'params', 'nofollow'); } /**