From 07ff0babae240ba072a3bc8b83a989c4305c24cd Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Wed, 31 Jul 2013 17:20:00 +0200 Subject: Fix the useheading cache invalidation for hidden pages, add tests This adds a new parameter to ft_backlinks() to ignore permissions which is needed for invalidating the cache of linking pages with useheading enabled. This also adds various test cases for ft_backlinks(). --- inc/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 1b4d9e8e4..bff6e80de 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1130,7 +1130,7 @@ function saveWikiText($id, $text, $summary, $minor = false) { // if useheading is enabled, purge the cache of all linking pages if(useHeading('content')) { - $pages = ft_backlinks($id); + $pages = ft_backlinks($id, true); foreach($pages as $page) { $cache = new cache_renderer($page, wikiFN($page), 'xhtml'); $cache->removeCache(); -- cgit v1.2.3 From cc036f74ff14c387f24d72f5a52f2f158208846e Mon Sep 17 00:00:00 2001 From: Klap-in Date: Thu, 1 Aug 2013 23:06:03 +0200 Subject: remove hash for external images, but use token url parameter instead --- inc/common.php | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 1b4d9e8e4..a34cf96c0 100644 --- a/inc/common.php +++ b/inc/common.php @@ -148,7 +148,7 @@ function pageinfo() { $info['id'] = $ID; $info['rev'] = $REV; - if(isset($_SERVER['REMOTE_USER'])) { + if(isset($_SERVER['REMOTE_USER'])) { $sub = new Subscription(); $info['subscribed'] = $sub->user_subscription(); } else { @@ -474,7 +474,7 @@ function ml($id = '', $more = '', $direct = true, $sep = '&', $abs = false) if(is_array($more)) { // add token for resized images - if($more['w'] || $more['h']){ + if($more['w'] || $more['h'] || $isexternalimage){ $more['tok'] = media_get_token($id,$more['w'],$more['h']); } // strip defaults for shorter URLs @@ -485,12 +485,13 @@ function ml($id = '', $more = '', $direct = true, $sep = '&', $abs = false) $more = buildURLparams($more, $sep); } else { $matches = array(); - if (preg_match_all('/\b(w|h)=(\d*)\b/',$more,$matches,PREG_SET_ORDER)){ + if (preg_match_all('/\b(w|h)=(\d*)\b/',$more,$matches,PREG_SET_ORDER) || $isexternalimage){ $resize = array('w'=>0, 'h'=>0); foreach ($matches as $match){ $resize[$match[1]] = $match[2]; } - $more .= $sep.'tok='.media_get_token($id,$resize['w'],$resize['h']); + $more .= $more === '' ? '' : $sep; + $more .= 'tok='.media_get_token($id,$resize['w'],$resize['h']); } $more = str_replace('cache=cache', '', $more); //skip default $more = str_replace(',,', ',', $more); @@ -506,14 +507,8 @@ function ml($id = '', $more = '', $direct = true, $sep = '&', $abs = false) // external URLs are always direct without rewriting if($isexternalimage) { $xlink .= 'lib/exe/fetch.php'; - // add hash: - $xlink .= '?hash='.substr(PassHash::hmac('md5', $id, auth_cookiesalt()), 0, 6); - if($more) { - $xlink .= $sep.$more; - $xlink .= $sep.'media='.rawurlencode($id); - } else { - $xlink .= $sep.'media='.rawurlencode($id); - } + $xlink .= '?'.$more; + $xlink .= $sep.'media='.rawurlencode($id); return $xlink; } -- cgit v1.2.3 From 75e4dd8a2ec6c181e99877919b5a2b529407752a Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Tue, 8 Oct 2013 00:06:46 +0200 Subject: Use in cookie a correct path, added DOKU_COOKIEPATH to js constants Fixes FS#2837 --- inc/common.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 3312141c8..866e0aadd 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1625,7 +1625,8 @@ function set_doku_pref($pref, $val) { } if (!empty($cookieVal)) { - setcookie('DOKU_PREFS', $cookieVal, time()+365*24*3600, DOKU_BASE, '', ($conf['securecookie'] && is_ssl())); + $cookieDir = empty($conf['cookiedir']) ? DOKU_REL : $conf['cookiedir']; + setcookie('DOKU_PREFS', $cookieVal, time()+365*24*3600, $cookieDir, '', ($conf['securecookie'] && is_ssl())); } } -- cgit v1.2.3 From 443e135d59e9d227eec818dabf9ee64d7a73d474 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Wed, 16 Oct 2013 22:04:01 +0100 Subject: replace boolean conditional checks on possibly uninitialized vars with \!empty/empty/isset as appropriate --- inc/common.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 866e0aadd..32771285b 100644 --- a/inc/common.php +++ b/inc/common.php @@ -64,7 +64,7 @@ function getSecurityToken() { */ function checkSecurityToken($token = null) { global $INPUT; - if(!$_SERVER['REMOTE_USER']) return true; // no logged in user, no need for a check + if(empty($_SERVER['REMOTE_USER'])) return true; // no logged in user, no need for a check if(is_null($token)) $token = $INPUT->str('sectok'); if(getSecurityToken() != $token) { @@ -474,13 +474,13 @@ function ml($id = '', $more = '', $direct = true, $sep = '&', $abs = false) if(is_array($more)) { // add token for resized images - if($more['w'] || $more['h'] || $isexternalimage){ + if(!empty($more['w']) || !empty($more['h']) || $isexternalimage){ $more['tok'] = media_get_token($id,$more['w'],$more['h']); } // strip defaults for shorter URLs if(isset($more['cache']) && $more['cache'] == 'cache') unset($more['cache']); - if(!$more['w']) unset($more['w']); - if(!$more['h']) unset($more['h']); + if(empty($more['w'])) unset($more['w']); + if(empty($more['h'])) unset($more['h']); if(isset($more['id']) && $direct) unset($more['id']); $more = buildURLparams($more, $sep); } else { -- cgit v1.2.3