summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--_test/tests/inc/tar.test.php23
-rw-r--r--inc/Tar.class.php28
-rw-r--r--inc/auth.php14
-rw-r--r--lib/plugins/acl/admin.php2
-rw-r--r--lib/tpl/dokuwiki/css/pagetools.less321
5 files changed, 110 insertions, 278 deletions
diff --git a/_test/tests/inc/tar.test.php b/_test/tests/inc/tar.test.php
index 9801ca1e0..417f1a853 100644
--- a/_test/tests/inc/tar.test.php
+++ b/_test/tests/inc/tar.test.php
@@ -58,6 +58,8 @@ class Tar_TestCase extends DokuWikiTest {
$tar->addData('another/testdata3.txt', 'testcontent3');
$tar->close();
+copy ($tmp, '/tmp/test.tar');
+
$this->assertTrue(filesize($tmp) > 30); //arbitrary non-zero number
$data = file_get_contents($tmp);
@@ -66,7 +68,7 @@ class Tar_TestCase extends DokuWikiTest {
$this->assertTrue(strpos($data, 'testcontent3') !== false, 'Content in TAR');
// fullpath might be too long to be stored as full path FS#2802
- $this->assertTrue(strpos($data, "$tdir") !== false, 'Path in TAR');
+ $this->assertTrue(strpos($data, "$tdir") !== false, "Path in TAR '$tdir'");
$this->assertTrue(strpos($data, "testdata1.txt") !== false, 'File in TAR');
$this->assertTrue(strpos($data, 'noway/testdata2.txt') !== false, 'Path in TAR');
@@ -396,4 +398,23 @@ class Tar_TestCase extends DokuWikiTest {
$this->assertEquals(512*4, strlen($file)); // 1 header block + data block + 2 footer blocks
}
+
+
+ public function test_cleanPath(){
+ $tar = new Tar();
+ $tests = array (
+ '/foo/bar' => 'foo/bar',
+ '/foo/bar/' => 'foo/bar',
+ 'foo//bar' => 'foo/bar',
+ 'foo/0/bar' => 'foo/0/bar',
+ 'foo/../bar' => 'bar',
+ 'foo/bang/bang/../../bar' => 'foo/bar',
+ 'foo/../../bar' => 'bar',
+ 'foo/.././../bar' => 'bar',
+ );
+
+ foreach($tests as $in => $out){
+ $this->assertEquals($out, $tar->cleanPath($in), "Input: $in");
+ }
+ }
}
diff --git a/inc/Tar.class.php b/inc/Tar.class.php
index d1a38ea0e..bc87d7d29 100644
--- a/inc/Tar.class.php
+++ b/inc/Tar.class.php
@@ -568,29 +568,23 @@ class Tar {
}
/**
- * Cleans up a path and removes relative parts
+ * Cleans up a path and removes relative parts, also strips leading slashes
*
* @param string $p_dir
* @return string
*/
- protected function cleanPath($p_dir) {
- $r = '';
- if($p_dir) {
- $subf = explode("/", $p_dir);
-
- for($i = count($subf) - 1; $i >= 0; $i--) {
- if($subf[$i] == ".") {
- # do nothing
- } elseif($subf[$i] == "..") {
- $i--;
- } elseif(!$subf[$i] && $i != count($subf) - 1 && $i) {
- # do nothing
- } else {
- $r = $subf[$i].($i != (count($subf) - 1) ? "/".$r : "");
- }
+ public function cleanPath($path) {
+ $path=explode('/', $path);
+ $newpath=array();
+ foreach($path as $p) {
+ if ($p === '' || $p === '.') continue;
+ if ($p==='..') {
+ array_pop($newpath);
+ continue;
}
+ array_push($newpath, $p);
}
- return $r;
+ return trim(implode('/', $newpath), '/');
}
/**
diff --git a/inc/auth.php b/inc/auth.php
index be6b7ebbe..1c0bf5b4f 100644
--- a/inc/auth.php
+++ b/inc/auth.php
@@ -136,22 +136,30 @@ function auth_loadACL() {
$acl = file($config_cascade['acl']['default']);
- //support user wildcard
$out = array();
foreach($acl as $line) {
$line = trim($line);
if($line{0} == '#') continue;
list($id,$rest) = preg_split('/\s+/',$line,2);
+ // substitue user wildcard first (its 1:1)
+ if(strstr($line, '%USER%')){
+ // if user is not logged in, this ACL line is meaningless - skip it
+ if (!isset($_SERVER['REMOTE_USER'])) continue;
+
+ $id = str_replace('%USER%',cleanID($_SERVER['REMOTE_USER']),$id);
+ $rest = str_replace('%USER%',auth_nameencode($_SERVER['REMOTE_USER']),$rest);
+ }
+
+ // substitute group wildcard (its 1:m)
if(strstr($line, '%GROUP%')){
+ // if user is not logged in, grps is empty, no output will be added (i.e. skipped)
foreach((array) $USERINFO['grps'] as $grp){
$nid = str_replace('%GROUP%',cleanID($grp),$id);
$nrest = str_replace('%GROUP%','@'.auth_nameencode($grp),$rest);
$out[] = "$nid\t$nrest";
}
} else {
- $id = str_replace('%USER%',cleanID($_SERVER['REMOTE_USER']),$id);
- $rest = str_replace('%USER%',auth_nameencode($_SERVER['REMOTE_USER']),$rest);
$out[] = "$id\t$rest";
}
}
diff --git a/lib/plugins/acl/admin.php b/lib/plugins/acl/admin.php
index 0d9cd742a..50377da81 100644
--- a/lib/plugins/acl/admin.php
+++ b/lib/plugins/acl/admin.php
@@ -724,7 +724,7 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
static $label = 0; //number labels
$ret = '';
- if($ispage && $setperm > AUTH_EDIT) $perm = AUTH_EDIT;
+ if($ispage && $setperm > AUTH_EDIT) $setperm = AUTH_EDIT;
foreach(array(AUTH_NONE,AUTH_READ,AUTH_EDIT,AUTH_CREATE,AUTH_UPLOAD,AUTH_DELETE) as $perm){
$label += 1;
diff --git a/lib/tpl/dokuwiki/css/pagetools.less b/lib/tpl/dokuwiki/css/pagetools.less
index b65e6fc0d..ecb3038c3 100644
--- a/lib/tpl/dokuwiki/css/pagetools.less
+++ b/lib/tpl/dokuwiki/css/pagetools.less
@@ -163,262 +163,71 @@
/*____________ all available icons in sprite ____________*/
-#dokuwiki__pagetools ul li a.edit:before {
- margin-top: -90px;
-}
-#dokuwiki__pagetools ul li a.edit {
- background-position: right -90px;
-}
-#dokuwiki__pagetools ul li a.edit:hover,
-#dokuwiki__pagetools ul li a.edit:active,
-#dokuwiki__pagetools ul li a.edit:focus {
- background-position: right -135px;
-}
-[dir=rtl] #dokuwiki__pagetools ul li a.edit {
- background-position: left -90px;
-}
-[dir=rtl] #dokuwiki__pagetools ul li a.edit:hover,
-[dir=rtl] #dokuwiki__pagetools ul li a.edit:active,
-[dir=rtl] #dokuwiki__pagetools ul li a.edit:focus {
- background-position: left -135px;
-}
-
-#dokuwiki__pagetools ul li a.create:before {
- margin-top: -180px;
-}
-#dokuwiki__pagetools ul li a.create {
- background-position: right -180px;
-}
-#dokuwiki__pagetools ul li a.create:hover,
-#dokuwiki__pagetools ul li a.create:active,
-#dokuwiki__pagetools ul li a.create:focus {
- background-position: right -225px;
-}
-[dir=rtl] #dokuwiki__pagetools ul li a.create {
- background-position: left -180px;
-}
-[dir=rtl] #dokuwiki__pagetools ul li a.create:hover,
-[dir=rtl] #dokuwiki__pagetools ul li a.create:active,
-[dir=rtl] #dokuwiki__pagetools ul li a.create:focus {
- background-position: left -225px;
-}
-
-#dokuwiki__pagetools ul li a.show {
- background-position: right -360px;
-}
-#dokuwiki__pagetools ul li a.show:before {
- margin-top: -360px;
-}
-#dokuwiki__pagetools ul li a.show:hover,
-#dokuwiki__pagetools ul li a.show:active,
-#dokuwiki__pagetools ul li a.show:focus {
- background-position: right -405px;
-}
-[dir=rtl] #dokuwiki__pagetools ul li a.show {
- background-position: left -360px;
-}
-[dir=rtl] #dokuwiki__pagetools ul li a.show:hover,
-[dir=rtl] #dokuwiki__pagetools ul li a.show:active,
-[dir=rtl] #dokuwiki__pagetools ul li a.show:focus {
- background-position: left -405px;
-}
-
-#dokuwiki__pagetools ul li a.source {
- background-position: right -450px;
-}
-#dokuwiki__pagetools ul li a.source:before {
- margin-top: -450px;
-}
-#dokuwiki__pagetools ul li a.source:hover,
-#dokuwiki__pagetools ul li a.source:active,
-#dokuwiki__pagetools ul li a.source:focus {
- background-position: right -495px;
-}
-[dir=rtl] #dokuwiki__pagetools ul li a.source {
- background-position: left -450px;
-}
-[dir=rtl] #dokuwiki__pagetools ul li a.source:hover,
-[dir=rtl] #dokuwiki__pagetools ul li a.source:active,
-[dir=rtl] #dokuwiki__pagetools ul li a.source:focus {
- background-position: left -495px;
-}
-
-#dokuwiki__pagetools ul li a.draft {
- background-position: right -270px;
-}
-#dokuwiki__pagetools ul li a.draft:before {
- margin-top: -270px;
-}
-#dokuwiki__pagetools ul li a.draft:hover,
-#dokuwiki__pagetools ul li a.draft:active,
-#dokuwiki__pagetools ul li a.draft:focus {
- background-position: right -315px;
-}
-[dir=rtl] #dokuwiki__pagetools ul li a.draft {
- background-position: left -270px;
-}
-[dir=rtl] #dokuwiki__pagetools ul li a.draft:hover,
-[dir=rtl] #dokuwiki__pagetools ul li a.draft:active,
-[dir=rtl] #dokuwiki__pagetools ul li a.draft:focus {
- background-position: left -315px;
-}
-
-#dokuwiki__pagetools ul li a.revs {
- background-position: right -630px;
-}
-#dokuwiki__pagetools ul li a.revs:before {
- margin-top: -630px;
-}
-#dokuwiki__pagetools ul li a.revs:hover,
-#dokuwiki__pagetools ul li a.revs:active,
-#dokuwiki__pagetools ul li a.revs:focus,
-.mode_revisions #dokuwiki__pagetools ul li a.revs {
- background-position: right -675px;
-}
-.mode_revisions #dokuwiki__pagetools ul li a.revs:before {
- margin-top: -675px;
-}
-[dir=rtl] #dokuwiki__pagetools ul li a.revs {
- background-position: left -630px;
-}
-[dir=rtl] #dokuwiki__pagetools ul li a.revs:hover,
-[dir=rtl] #dokuwiki__pagetools ul li a.revs:active,
-[dir=rtl] #dokuwiki__pagetools ul li a.revs:focus,
-[dir=rtl] .mode_revisions #dokuwiki__pagetools ul li a.revs {
- background-position: left -675px;
-}
-
-#dokuwiki__pagetools ul li a.backlink {
- background-position: right -720px;
-}
-#dokuwiki__pagetools ul li a.backlink:before {
- margin-top: -720px;
-}
-#dokuwiki__pagetools ul li a.backlink:hover,
-#dokuwiki__pagetools ul li a.backlink:active,
-#dokuwiki__pagetools ul li a.backlink:focus,
-.mode_backlink #dokuwiki__pagetools ul li a.backlink {
- background-position: right -765px;
-}
-.mode_backlink #dokuwiki__pagetools ul li a.backlink:before {
- margin-top: -765px;
-}
-[dir=rtl] #dokuwiki__pagetools ul li a.backlink {
- background-position: left -720px;
-}
-[dir=rtl] #dokuwiki__pagetools ul li a.backlink:hover,
-[dir=rtl] #dokuwiki__pagetools ul li a.backlink:active,
-[dir=rtl] #dokuwiki__pagetools ul li a.backlink:focus,
-[dir=rtl] .mode_backlink #dokuwiki__pagetools ul li a.backlink {
- background-position: left -765px;
-}
-
-#dokuwiki__pagetools ul li a.top {
- background-position: right -900px;
-}
-#dokuwiki__pagetools ul li a.top:before{
- margin-top: -900px;
-}
-#dokuwiki__pagetools ul li a.top:hover,
-#dokuwiki__pagetools ul li a.top:active,
-#dokuwiki__pagetools ul li a.top:focus {
- background-position: right -945px;
-}
-[dir=rtl] #dokuwiki__pagetools ul li a.top {
- background-position: left -900px;
-}
-[dir=rtl] #dokuwiki__pagetools ul li a.top:hover,
-[dir=rtl] #dokuwiki__pagetools ul li a.top:active,
-[dir=rtl] #dokuwiki__pagetools ul li a.top:focus {
- background-position: left -945px;
-}
+@pagetools_icon_space: -90px;
-#dokuwiki__pagetools ul li a.revert {
- background-position: right -540px;
-}
-#dokuwiki__pagetools ul li a.revert:before {
- margin-top: -540px;
-}
-#dokuwiki__pagetools ul li a.revert:hover,
-#dokuwiki__pagetools ul li a.revert:active,
-#dokuwiki__pagetools ul li a.revert:focus,
-.mode_revert #dokuwiki__pagetools ul li a.revert {
- background-position: right -585px;
-}
-.mode_revert #dokuwiki__pagetools ul li a.revert:before {
- margin-top: -540px;
-}
-[dir=rtl] #dokuwiki__pagetools ul li a.revert {
- background-position: left -540px;
-}
-[dir=rtl] #dokuwiki__pagetools ul li a.revert:hover,
-[dir=rtl] #dokuwiki__pagetools ul li a.revert:active,
-[dir=rtl] #dokuwiki__pagetools ul li a.revert:focus,
-[dir=rtl] .mode_revert #dokuwiki__pagetools ul li a.revert {
- background-position: left -585px;
-}
-
-#dokuwiki__pagetools ul li a.subscribe {
- background-position: right -810px;
-}
-#dokuwiki__pagetools ul li a.subscribe:before {
- margin-top: -810px;
-}
-#dokuwiki__pagetools ul li a.subscribe:hover,
-#dokuwiki__pagetools ul li a.subscribe:active,
-#dokuwiki__pagetools ul li a.subscribe:focus,
-.mode_subscribe #dokuwiki__pagetools ul li a.subscribe {
- background-position: right -855px;
-}
-.mode_subscribe #dokuwiki__pagetools ul li a.subscribe:before {
- margin-top: -855px;
-}
-[dir=rtl] #dokuwiki__pagetools ul li a.subscribe {
- background-position: left -810px;
-}
-[dir=rtl] #dokuwiki__pagetools ul li a.subscribe:hover,
-[dir=rtl] #dokuwiki__pagetools ul li a.subscribe:active,
-[dir=rtl] #dokuwiki__pagetools ul li a.subscribe:focus,
-[dir=rtl] .mode_subscribe #dokuwiki__pagetools ul li a.subscribe {
- background-position: left -855px;
-}
-
-#dokuwiki__pagetools ul li a.mediaManager {
- background-position: right -990px;
-}
-#dokuwiki__pagetools ul li a.mediaManager:before {
- margin-top: -990px;
-}
-#dokuwiki__pagetools ul li a.mediaManager:hover,
-#dokuwiki__pagetools ul li a.mediaManager:active,
-#dokuwiki__pagetools ul li a.mediaManager:focus {
- background-position: right -1035px;
-}
-[dir=rtl] #dokuwiki__pagetools ul li a.mediaManager {
- background-position: left -990px;
-}
-[dir=rtl] #dokuwiki__pagetools ul li a.mediaManager:hover,
-[dir=rtl] #dokuwiki__pagetools ul li a.mediaManager:active,
-[dir=rtl] #dokuwiki__pagetools ul li a.mediaManager:focus {
- background-position: left -1035px;
+/**
+ * page tools without highlighting
+ *
+ * @param string @action The action class
+ * @param int @position Position in the page tools sprite
+ */
+.pagetools-item(@action, @position) {
+ @position-active: (@position+0.5);
+
+ #dokuwiki__pagetools ul li a.@{action} {
+ background-position: right @pagetools_icon_space * @position;
+
+ &:before {
+ margin-top: @pagetools_icon_space * @position;
+ }
+ &:hover,
+ &:active,
+ &:focus {
+ background-position: right @pagetools_icon_space * @position-active;
+ }
+ }
+ [dir=rtl] #dokuwiki__pagetools ul li a.@{action} {
+ background-position: left @pagetools_icon_space * @position;
+
+ &:hover,
+ &:active,
+ &:focus {
+ background-position: left @pagetools_icon_space * @position-active;
+ }
+ }
}
-#dokuwiki__pagetools ul li a.back {
- background-position: right -1080px;
-}
-#dokuwiki__pagetools ul li a.back:before {
- margin-top: -1080px;
-}
-#dokuwiki__pagetools ul li a.back:hover,
-#dokuwiki__pagetools ul li a.back:active,
-#dokuwiki__pagetools ul li a.back:focus {
- background-position: right -1125px;
-}
-[dir=rtl] #dokuwiki__pagetools ul li a.back {
- background-position: left -1080px;
-}
-[dir=rtl] #dokuwiki__pagetools ul li a.back:hover,
-[dir=rtl] #dokuwiki__pagetools ul li a.back:active,
-[dir=rtl] #dokuwiki__pagetools ul li a.back:focus {
- background-position: left -1125px;
-}
+/**
+ * page tools with highlighting
+ *
+ * @param string @action The action class
+ * @param int @position Position in the page tools sprite
+ * @param string @mode The mode in which this tool should be highlighted
+ */
+.pagetools-item(@action, @position, @mode) {
+ .pagetools-item(@action, @position);
+ @position-active: (@position+0.5);
+
+ .mode_@{mode} #dokuwiki__pagetools ul li a.@{action} {
+ background-position: right @pagetools_icon_space * @position-active;
+ &:before {
+ margin-top: @pagetools_icon_space * @position-active;
+ }
+ }
+ [dir=rtl] .mode_@{mode} #dokuwiki__pagetools ul li a.@{action} {
+ background-position: left @pagetools_icon_space * @position-active;
+ }
+}
+
+.pagetools-item(edit, 1);
+.pagetools-item(create, 2);
+.pagetools-item(show, 4);
+.pagetools-item(source, 5);
+.pagetools-item(draft, 3);
+.pagetools-item(revs, 7, revisions);
+.pagetools-item(backlink, 8, backlink);
+.pagetools-item(top, 10);
+.pagetools-item(revert, 6, revert);
+.pagetools-item(subscribe, 9, subscribe);
+.pagetools-item(mediaManager, 11);
+.pagetools-item(back, 12);