diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/exe/css.php | 3 | ||||
-rw-r--r-- | lib/exe/js.php | 34 | ||||
-rw-r--r-- | lib/plugins/auth.php | 2 | ||||
-rw-r--r-- | lib/plugins/authplain/_test/escaping.test.php | 43 | ||||
-rw-r--r-- | lib/plugins/authplain/auth.php | 34 | ||||
-rw-r--r-- | lib/plugins/extension/lang/hr/lang.php | 20 | ||||
-rw-r--r-- | lib/plugins/usermanager/lang/hr/lang.php | 4 |
7 files changed, 112 insertions, 28 deletions
diff --git a/lib/exe/css.php b/lib/exe/css.php index 6c1d60751..f7235fd4e 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -166,8 +166,11 @@ function css_out(){ * @return string */ function css_parseless($css) { + global $conf; + $less = new lessc(); $less->importDir[] = DOKU_INC; + $less->setPreserveComments(!$conf['compress']); if (defined('DOKU_UNITTEST')){ $less->importDir[] = TMP_DIR; diff --git a/lib/exe/js.php b/lib/exe/js.php index bec12ef7a..2ab78dfc3 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -289,6 +289,10 @@ function js_compress($s){ // items that don't need spaces next to them $chars = "^&|!+\-*\/%=\?:;,{}()<>% \t\n\r'\"[]"; + // items which need a space if the sign before and after whitespace is equal. + // E.g. '+ ++' may not be compressed to '+++' --> syntax error. + $ops = "+-"; + $regex_starters = array("(", "=", "[", "," , ":", "!"); $whitespaces_chars = array(" ", "\t", "\n", "\r", "\0", "\x0B"); @@ -389,19 +393,27 @@ function js_compress($s){ // whitespaces if( $ch == ' ' || $ch == "\r" || $ch == "\n" || $ch == "\t" ){ - // leading spaces - if($i+1 < $slen && (strpos($chars,$s[$i+1]) !== false)){ - $i = $i + 1; - continue; - } - // trailing spaces - // if this ch is space AND the last char processed - // is special, then skip the space $lch = substr($result,-1); - if($lch && (strpos($chars,$lch) !== false)){ - $i = $i + 1; - continue; + + // Only consider deleting whitespace if the signs before and after + // are not equal and are not an operator which may not follow itself. + if ((!$lch || $s[$i+1] == ' ') + || $lch != $s[$i+1] + || strpos($ops,$s[$i+1]) === false) { + // leading spaces + if($i+1 < $slen && (strpos($chars,$s[$i+1]) !== false)){ + $i = $i + 1; + continue; + } + // trailing spaces + // if this ch is space AND the last char processed + // is special, then skip the space + if($lch && (strpos($chars,$lch) !== false)){ + $i = $i + 1; + continue; + } } + // else after all of this convert the "whitespace" to // a single space. It will get appended below $ch = ' '; diff --git a/lib/plugins/auth.php b/lib/plugins/auth.php index b38b591a3..02e0613dd 100644 --- a/lib/plugins/auth.php +++ b/lib/plugins/auth.php @@ -129,7 +129,7 @@ class DokuWiki_Auth_Plugin extends DokuWiki_Plugin { $eventdata = array('type' => $type, 'params' => $params, 'modification_result' => null); $evt = new Doku_Event('AUTH_USER_CHANGE', $eventdata); if($evt->advise_before(true)) { - $result = call_user_func_array(array($this, $validTypes[$type]), $params); + $result = call_user_func_array(array($this, $validTypes[$type]), $evt->data['params']); $evt->data['modification_result'] = $result; } $evt->advise_after(); diff --git a/lib/plugins/authplain/_test/escaping.test.php b/lib/plugins/authplain/_test/escaping.test.php index cd5294157..cbfbbc587 100644 --- a/lib/plugins/authplain/_test/escaping.test.php +++ b/lib/plugins/authplain/_test/escaping.test.php @@ -13,12 +13,12 @@ */ class helper_plugin_authplain_escaping_test extends DokuWikiTest { - protected $pluginsEnabled = array('authplain'); + protected $pluginsEnabled = array('authplainharness'); protected $auth; protected function reloadUsers() { /* auth caches data loaded from file, but recreated object forces reload */ - $this->auth = new auth_plugin_authplain(); + $this->auth = new auth_plugin_authplainharness(); } function setUp() { @@ -76,7 +76,44 @@ class helper_plugin_authplain_escaping_test extends DokuWikiTest { $this->assertEquals($saved['name'], $user['name']); $this->assertTrue($this->auth->checkPass("testuser", $user['pass'])); } + + // really only required for developers to ensure this plugin will + // work with systems running on PCRE 6.6 and lower. + public function testLineSplit(){ + $this->auth->setPregsplit_safe(false); + + $names = array( + 'plain', + 'ut-fठ8', + 'colon:', + 'backslash\\', + 'alltogether\\ठ:' + ); + $userpass = 'user:password_hash:'; + $other_user_data = ':email@address:group1,group2'; + + foreach ($names as $testname) { + $escaped = str_replace(array('\\',':'),array('\\\\','\\:'),$testname); // escape : & \ + $test_line = $userpass.$escaped.$other_user_data; + $result = $this->auth->splitUserData($test_line); + + $this->assertEquals($escaped, $result[2]); + } + } } -?>
\ No newline at end of file +class auth_plugin_authplainharness extends auth_plugin_authplain { + + public function setPregsplit_safe($bool) { + $this->_pregsplit_safe = $bool; + } + + public function getPregsplit_safe(){ + return $this->_pregsplit_safe; + } + + public function splitUserData($line){ + return $this->_splitUserData($line); + } +}
\ No newline at end of file diff --git a/lib/plugins/authplain/auth.php b/lib/plugins/authplain/auth.php index b3ca988b9..3d303597c 100644 --- a/lib/plugins/authplain/auth.php +++ b/lib/plugins/authplain/auth.php @@ -17,6 +17,9 @@ class auth_plugin_authplain extends DokuWiki_Auth_Plugin { /** @var array filter pattern */ protected $_pattern = array(); + /** @var bool safe version of preg_split */ + protected $_pregsplit_safe = false; + /** * Constructor * @@ -44,6 +47,8 @@ class auth_plugin_authplain extends DokuWiki_Auth_Plugin { $this->cando['getUsers'] = true; $this->cando['getUserCount'] = true; } + + $this->_pregsplit_safe = version_compare(PCRE_VERSION,'6.7','>='); } /** @@ -329,7 +334,7 @@ class auth_plugin_authplain extends DokuWiki_Auth_Plugin { if(empty($line)) continue; /* NB: preg_split can be deprecated/replaced with str_getcsv once dokuwiki is min php 5.3 */ - $row = preg_split('/(?<![^\\\\]\\\\)\:/', $line, 5); // allow for : escaped as \: + $row = $this->_splitUserData($line); $row = str_replace('\\:', ':', $row); $row = str_replace('\\\\', '\\', $row); @@ -342,6 +347,33 @@ class auth_plugin_authplain extends DokuWiki_Auth_Plugin { } } + protected function _splitUserData($line){ + // due to a bug in PCRE 6.6, preg_split will fail with the regex we use here + // refer github issues 877 & 885 + if ($this->_pregsplit_safe){ + return preg_split('/(?<![^\\\\]\\\\)\:/', $line, 5); // allow for : escaped as \: + } + + $row = array(); + $piece = ''; + $len = strlen($line); + for($i=0; $i<$len; $i++){ + if ($line[$i]=='\\'){ + $piece .= $line[$i]; + $i++; + if ($i>=$len) break; + } else if ($line[$i]==':'){ + $row[] = $piece; + $piece = ''; + continue; + } + $piece .= $line[$i]; + } + $row[] = $piece; + + return $row; + } + /** * return true if $user + $info match $filter criteria, false otherwise * diff --git a/lib/plugins/extension/lang/hr/lang.php b/lib/plugins/extension/lang/hr/lang.php index 4905fe864..f43defcb1 100644 --- a/lib/plugins/extension/lang/hr/lang.php +++ b/lib/plugins/extension/lang/hr/lang.php @@ -6,24 +6,24 @@ * @author Davor Turkalj <turki.bsc@gmail.com> */ $lang['menu'] = 'Upravitelj dodataka'; -$lang['tab_plugins'] = 'Instalirani dodatci'; -$lang['tab_templates'] = 'Instalirani predlošci'; -$lang['tab_search'] = 'Potraži i instaliraj'; -$lang['tab_install'] = 'Ručno instaliranje'; +$lang['tab_plugins'] = 'Ugrađeni dodatci'; +$lang['tab_templates'] = 'Ugrađeni predlošci'; +$lang['tab_search'] = 'Potraži i ugradi'; +$lang['tab_install'] = 'Ručna ugradnja'; $lang['notimplemented'] = 'Ova mogućnost još nije napravljena'; -$lang['notinstalled'] = 'Dodatak nije instaliran'; +$lang['notinstalled'] = 'Dodatak nije ugrađen'; $lang['alreadyenabled'] = 'Ovaj dodatak je već omogućen'; $lang['alreadydisabled'] = 'Ovaj dodatak je već onemogućen'; $lang['pluginlistsaveerror'] = 'Dogodila se greška pri snimanju liste dodataka'; $lang['unknownauthor'] = 'Nepoznat autor'; $lang['unknownversion'] = 'Nepoznata inačica'; $lang['btn_info'] = 'Prikaži više informacija'; -$lang['btn_update'] = 'Dopuni'; +$lang['btn_update'] = 'Dogradi'; $lang['btn_uninstall'] = 'Ukloni'; $lang['btn_enable'] = 'Omogući'; $lang['btn_disable'] = 'Onemogući'; -$lang['btn_install'] = 'Postavi'; -$lang['btn_reinstall'] = 'Ponovno postavi'; +$lang['btn_install'] = 'Ugradi'; +$lang['btn_reinstall'] = 'Ponovno ugradi'; $lang['js']['reallydel'] = 'Zaista ukloniti ovo proširenje?'; $lang['search_for'] = 'Pretraži proširenja'; $lang['search'] = 'Pretraži'; @@ -34,11 +34,11 @@ $lang['homepage_link'] = 'Upute'; $lang['bugs_features'] = 'Greške'; $lang['tags'] = 'Oznake:'; $lang['author_hint'] = 'Potraži dodatke od ovog autora'; -$lang['installed'] = 'Postavljeno:'; +$lang['installed'] = 'Ugrađeno:'; $lang['downloadurl'] = 'URL adresa preuzimanja:'; $lang['repository'] = 'Repozitorij:'; $lang['unknown'] = '<em>nepoznat</em>'; -$lang['installed_version'] = 'Postavljena inačica:'; +$lang['installed_version'] = 'Ugrađena inačica:'; $lang['install_date'] = 'Vaše zadnje osvježavanje:'; $lang['available_version'] = 'Dostupna inačica'; $lang['compatible'] = 'Kompatibilan s:'; diff --git a/lib/plugins/usermanager/lang/hr/lang.php b/lib/plugins/usermanager/lang/hr/lang.php index 80613ed6f..a71afb60a 100644 --- a/lib/plugins/usermanager/lang/hr/lang.php +++ b/lib/plugins/usermanager/lang/hr/lang.php @@ -33,7 +33,7 @@ $lang['line'] = 'Linija br.'; $lang['error'] = 'Poruka o grešci'; $lang['summary'] = 'Prikaz korisnika %1$d-%2$d od %3$d nađenih. Ukupno %4$d korisnika.'; $lang['nonefound'] = 'Nema korisnika koji odgovaraju filtru.Ukupno %d korisnika.'; -$lang['delete_ok'] = '%d korisnik obrisano'; +$lang['delete_ok'] = '%d korisnika obrisano'; $lang['delete_fail'] = '%d neuspjelih brisanja.'; $lang['update_ok'] = 'Korisnik uspješno izmijenjen'; $lang['update_fail'] = 'Neuspjela izmjena korisnika'; @@ -49,7 +49,7 @@ $lang['note_group'] = 'Novi korisnik biti će dodijeljen u podrazumij $lang['note_pass'] = 'Lozinka će biti generirana ako se polje ostavi prazno i obavješćivanje korisnika je omogućeno.'; $lang['add_ok'] = 'Korisnik uspješno dodan'; $lang['add_fail'] = 'Neuspješno dodavanje korisnika'; -$lang['notify_ok'] = 'Obavijest korisniku poslana'; +$lang['notify_ok'] = 'Poslana obavijest korisniku'; $lang['notify_fail'] = 'Obavijest korisniku ne može biti poslana'; $lang['import_userlistcsv'] = 'Datoteka s popisom korisnika (CSV):'; $lang['import_header'] = 'Zadnje greške pri uvozu'; |