From b8983d3a45d16afc81d527fc2616f8c43bbf2c87 Mon Sep 17 00:00:00 2001 From: Matt Perry Date: Tue, 20 Aug 2013 21:18:30 -0700 Subject: Fix CodeSniffer violations Remove whitespace from end of lines to reduce the number of CodeSniffer violations. --- lib/exe/detail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/exe') diff --git a/lib/exe/detail.php b/lib/exe/detail.php index 7008b126f..7aae08f76 100644 --- a/lib/exe/detail.php +++ b/lib/exe/detail.php @@ -11,8 +11,8 @@ $ID = cleanID($INPUT->str('id')); $INFO = array_merge(pageinfo(),mediainfo()); trigger_event('DETAIL_STARTED', $tmp=array()); -//close session -session_write_close(); +//close session +session_write_close(); if($conf['allowdebug'] && $INPUT->has('debug')){ print '
';
-- 
cgit v1.2.3


From d91ab76f52f59d264301e18c28a0d3bae996fab8 Mon Sep 17 00:00:00 2001
From: Matt Perry 
Date: Tue, 27 Aug 2013 01:18:10 -0700
Subject: Fix CodeSniffer violations

Fix violations for the following sniff
DokuWiki.Functions.OpeningFunctionBrace

Also removed an extraneous semicolon.
---
 lib/exe/css.php | 3 +--
 lib/exe/js.php  | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

(limited to 'lib/exe')

diff --git a/lib/exe/css.php b/lib/exe/css.php
index 9e1e22e1a..60e17ae82 100644
--- a/lib/exe/css.php
+++ b/lib/exe/css.php
@@ -465,8 +465,7 @@ function css_pluginstyles($mediatype='screen'){
  *
  * @author Gabriel Birke 
  */
-function css_moveimports($css)
-{
+function css_moveimports($css) {
     if(!preg_match_all('/@import\s+(?:url\([^)]+\)|"[^"]+")\s*[^;]*;\s*/', $css, $matches, PREG_OFFSET_CAPTURE)) {
         return $css;
     }
diff --git a/lib/exe/js.php b/lib/exe/js.php
index 4b4b598de..76238a81b 100644
--- a/lib/exe/js.php
+++ b/lib/exe/js.php
@@ -194,8 +194,7 @@ function js_pluginscripts(){
  *
  * @author Gabriel Birke 
  */
-function js_pluginstrings()
-{
+function js_pluginstrings() {
     global $conf;
     $pluginstrings = array();
     $plugins = plugin_list();
-- 
cgit v1.2.3


From f591e7b075b936baf7357625ef7edb37fe4feaa3 Mon Sep 17 00:00:00 2001
From: Matt Perry 
Date: Tue, 27 Aug 2013 01:45:47 -0700
Subject: Fix CodeSniffer violations

Fix violations for the following sniff
DokuWiki.WhiteSpace.ScopeIndent
---
 lib/exe/indexer.php | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

(limited to 'lib/exe')

diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php
index 57bee8925..3ab117736 100644
--- a/lib/exe/indexer.php
+++ b/lib/exe/indexer.php
@@ -31,12 +31,12 @@ else header('Content-Type: text/plain');
 $tmp = array(); // No event data
 $evt = new Doku_Event('INDEXER_TASKS_RUN', $tmp);
 if ($evt->advise_before()) {
-  runIndexer() or
-  runSitemapper() or
-  sendDigest() or
-  runTrimRecentChanges() or
-  runTrimRecentChanges(true) or
-  $evt->advise_after();
+    runIndexer() or
+    runSitemapper() or
+    sendDigest() or
+    runTrimRecentChanges() or
+    runTrimRecentChanges(true) or
+    $evt->advise_after();
 }
 
 if(!$output) {
@@ -85,13 +85,13 @@ function runTrimRecentChanges($media_changes = false) {
             $out_lines = array();
 
             for ($i=0; $i
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

---
 lib/exe/js.php | 1 +
 1 file changed, 1 insertion(+)

(limited to 'lib/exe')

diff --git a/lib/exe/js.php b/lib/exe/js.php
index 76238a81b..fc7a869c2 100644
--- a/lib/exe/js.php
+++ b/lib/exe/js.php
@@ -89,6 +89,7 @@ function js_out(){
     // add some global variables
     print "var DOKU_BASE   = '".DOKU_BASE."';";
     print "var DOKU_TPL    = '".tpl_basedir()."';";
+    print "var DOKU_COOKIEPATH = '" . (empty($conf['cookiedir']) ? DOKU_REL : $conf['cookiedir']) . "';";
     // FIXME: Move those to JSINFO
     print "var DOKU_UHN    = ".((int) useHeading('navigation')).";";
     print "var DOKU_UHC    = ".((int) useHeading('content')).";";
-- 
cgit v1.2.3


From df5d307ea8bac1f5030d42af363ae9f7469a63f2 Mon Sep 17 00:00:00 2001
From: Gerrit Uitslag 
Date: Thu, 10 Oct 2013 15:53:03 +0200
Subject: add cookie secure parameter to cookies set by javascript

---
 lib/exe/js.php | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

(limited to 'lib/exe')

diff --git a/lib/exe/js.php b/lib/exe/js.php
index fc7a869c2..040b8874d 100644
--- a/lib/exe/js.php
+++ b/lib/exe/js.php
@@ -86,16 +86,20 @@ function js_out(){
     // start output buffering and build the script
     ob_start();
 
+    $json = new JSON();
     // add some global variables
     print "var DOKU_BASE   = '".DOKU_BASE."';";
     print "var DOKU_TPL    = '".tpl_basedir()."';";
-    print "var DOKU_COOKIEPATH = '" . (empty($conf['cookiedir']) ? DOKU_REL : $conf['cookiedir']) . "';";
+    print "var DOKU_COOKIE_PARAM = " . $json->encode(
+            array(
+                 'path' => empty($conf['cookiedir']) ? DOKU_REL : $conf['cookiedir'],
+                 'secure' => $conf['securecookie'] && is_ssl()
+            )).";";
     // FIXME: Move those to JSINFO
     print "var DOKU_UHN    = ".((int) useHeading('navigation')).";";
     print "var DOKU_UHC    = ".((int) useHeading('content')).";";
 
     // load JS specific translations
-    $json = new JSON();
     $lang['js']['plugins'] = js_pluginstrings();
     $templatestrings = js_templatestrings();
     if(!empty($templatestrings)) {
-- 
cgit v1.2.3


From 9c7a681b5de7bebb468569a1a416000935b3b3d7 Mon Sep 17 00:00:00 2001
From: Andreas Gohr 
Date: Sat, 12 Oct 2013 18:56:40 +0200
Subject: removed css_moveimports() this is now done by lessphp

---
 lib/exe/css.php | 25 -------------------------
 1 file changed, 25 deletions(-)

(limited to 'lib/exe')

diff --git a/lib/exe/css.php b/lib/exe/css.php
index 60e17ae82..afba5fc02 100644
--- a/lib/exe/css.php
+++ b/lib/exe/css.php
@@ -148,9 +148,6 @@ function css_out(){
     // parse less
     $css = css_parseless($css);
 
-    // place all remaining @import statements at the top of the file
-    $css = css_moveimports($css);
-
     // compress whitespace and comments
     if($conf['compress']){
         $css = css_compress($css);
@@ -459,28 +456,6 @@ function css_pluginstyles($mediatype='screen'){
     return $list;
 }
 
-/**
- * Move all @import statements in a combined stylesheet to the top so they
- * aren't ignored by the browser.
- *
- * @author Gabriel Birke 
- */
-function css_moveimports($css) {
-    if(!preg_match_all('/@import\s+(?:url\([^)]+\)|"[^"]+")\s*[^;]*;\s*/', $css, $matches, PREG_OFFSET_CAPTURE)) {
-        return $css;
-    }
-    $newCss  = "";
-    $imports = "";
-    $offset  = 0;
-    foreach($matches[0] as $match) {
-        $newCss  .= substr($css, $offset, $match[1] - $offset);
-        $imports .= $match[0];
-        $offset   = $match[1] + strlen($match[0]);
-    }
-    $newCss .= substr($css, $offset);
-    return $imports.$newCss;
-}
-
 /**
  * Very simple CSS optimizer
  *
-- 
cgit v1.2.3


From 205907a73eaf15c53de98f153e90890706e79cbe Mon Sep 17 00:00:00 2001
From: furun 
Date: Tue, 15 Oct 2013 11:34:31 +0200
Subject: compact some CSS styles to their shorthand syntax FS#2509

---
 lib/exe/css.php | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

(limited to 'lib/exe')

diff --git a/lib/exe/css.php b/lib/exe/css.php
index afba5fc02..6dfdf06e8 100644
--- a/lib/exe/css.php
+++ b/lib/exe/css.php
@@ -473,8 +473,19 @@ function css_compress($css){
     $css = preg_replace('/ ?([;,{}\/]) ?/','\\1',$css);
     $css = preg_replace('/ ?: /',':',$css);
 
+    // number compression
+    $css = preg_replace('/([: ])0+(\.\d+?)0*((?:pt|pc|in|mm|cm|em|ex|px)\b|%)(?=[^\{]*[;\}])/', '$1$2$3', $css); // "0.1em" to ".1em", "1.10em" to "1.1em"
+    $css = preg_replace('/([: ])\.(0)+((?:pt|pc|in|mm|cm|em|ex|px)\b|%)(?=[^\{]*[;\}])/', '$1$2', $css); // ".0em" to "0"
+    $css = preg_replace('/([: ]0)0*(\.0*)?((?:pt|pc|in|mm|cm|em|ex|px)(?=[^\{]*[;\}])\b|%)/', '$1', $css); // "0.0em" to "0"
+    $css = preg_replace('/([: ]\d+)(\.0*)((?:pt|pc|in|mm|cm|em|ex|px)(?=[^\{]*[;\}])\b|%)/', '$1$3', $css); // "1.0em" to "1em"
+    $css = preg_replace('/([: ])0+(\d+|\d*\.\d+)((?:pt|pc|in|mm|cm|em|ex|px)(?=[^\{]*[;\}])\b|%)/', '$1$2$3', $css); // "001em" to "1em"
+
+    // shorten attributes (1em 1em 1em 1em -> 1em)
+    $css = preg_replace('/(?
Date: Tue, 15 Oct 2013 16:36:56 +0200
Subject: fix expression passed by reference

---
 lib/exe/detail.php       | 4 +++-
 lib/exe/mediamanager.php | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)

(limited to 'lib/exe')

diff --git a/lib/exe/detail.php b/lib/exe/detail.php
index 7aae08f76..e3c81d877 100644
--- a/lib/exe/detail.php
+++ b/lib/exe/detail.php
@@ -9,7 +9,9 @@ $ID   = cleanID($INPUT->str('id'));
 // this makes some general infos available as well as the info about the
 // "parent" page
 $INFO = array_merge(pageinfo(),mediainfo());
-trigger_event('DETAIL_STARTED', $tmp=array());
+
+$tmp = array();
+trigger_event('DETAIL_STARTED', $tmp);
 
 //close session
 session_write_close();
diff --git a/lib/exe/mediamanager.php b/lib/exe/mediamanager.php
index d9e4a6b04..d94a24c74 100644
--- a/lib/exe/mediamanager.php
+++ b/lib/exe/mediamanager.php
@@ -34,7 +34,8 @@
     $JSINFO = array('id' => '', 'namespace' => '');
     $AUTH = $INFO['perm'];    // shortcut for historical reasons
 
-    trigger_event('MEDIAMANAGER_STARTED',$tmp=array());
+    $tmp = array();
+    trigger_event('MEDIAMANAGER_STARTED', $tmp);
     session_write_close();  //close session
 
     // do not display the manager if user does not have read access
-- 
cgit v1.2.3


From 6a5d68178752212e9dc2ef82d500940b49bf6500 Mon Sep 17 00:00:00 2001
From: Anika Henke 
Date: Sun, 3 Nov 2013 20:49:30 +0000
Subject: Revert "Fixes validation problems with base64 encoded images in CSS."

This reverts commit 88833bac87e7fb295c0479a8260d1d63051bca8d.
and fixes FS#2874
---
 lib/exe/css.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'lib/exe')

diff --git a/lib/exe/css.php b/lib/exe/css.php
index 6dfdf06e8..f0bd24b43 100644
--- a/lib/exe/css.php
+++ b/lib/exe/css.php
@@ -422,7 +422,7 @@ function css_datauri($match){
         $data = base64_encode(file_get_contents($local));
     }
     if($data){
-        $url = '\'data:image/'.$ext.';base64,'.$data.'\'';
+        $url = 'data:image/'.$ext.';base64,'.$data;
     }else{
         $url = $base.$url;
     }
-- 
cgit v1.2.3


From 8c867678811e7f91159175c41ef4722a2fc5308c Mon Sep 17 00:00:00 2001
From: Anika Henke 
Date: Mon, 4 Nov 2013 01:17:09 +0000
Subject: removed loading of deprecated RTL styles

---
 lib/exe/css.php | 15 ---------------
 1 file changed, 15 deletions(-)

(limited to 'lib/exe')

diff --git a/lib/exe/css.php b/lib/exe/css.php
index f0bd24b43..87fb779eb 100644
--- a/lib/exe/css.php
+++ b/lib/exe/css.php
@@ -84,16 +84,6 @@ function css_out(){
         if(isset($config_cascade['userstyle'][$mediatype])){
             $files[$mediatype][$config_cascade['userstyle'][$mediatype]] = DOKU_BASE;
         }
-        // load rtl styles
-        // note: this adds the rtl styles only to the 'screen' media type
-        // @deprecated 2012-04-09: rtl will cease to be a mode of its own,
-        //     please use "[dir=rtl]" in any css file in all, screen or print mode instead
-        if ($mediatype=='screen') {
-            if($lang['direction'] == 'rtl'){
-                if (isset($styleini['stylesheets']['rtl'])) $files[$mediatype] = array_merge($files[$mediatype], $styleini['stylesheets']['rtl']);
-                if (isset($config_cascade['userstyle']['rtl'])) $files[$mediatype][$config_cascade['userstyle']['rtl']] = DOKU_BASE;
-            }
-        }
 
         $cache_files = array_merge($cache_files, array_keys($files[$mediatype]));
     }
@@ -447,11 +437,6 @@ function css_pluginstyles($mediatype='screen'){
             $list[DOKU_PLUGIN."$p/style.css"]  = DOKU_BASE."lib/plugins/$p/";
             $list[DOKU_PLUGIN."$p/style.less"]  = DOKU_BASE."lib/plugins/$p/";
         }
-        // @deprecated 2012-04-09: rtl will cease to be a mode of its own,
-        //     please use "[dir=rtl]" in any css file in all, screen or print mode instead
-        if($lang['direction'] == 'rtl'){
-            $list[DOKU_PLUGIN."$p/rtl.css"] = DOKU_BASE."lib/plugins/$p/";
-        }
     }
     return $list;
 }
-- 
cgit v1.2.3


From 30f686eb67205a1da8765c992e2f9ee1a158c712 Mon Sep 17 00:00:00 2001
From: Christopher Smith 
Date: Tue, 5 Nov 2013 20:15:00 +0000
Subject: add DOKU_INC to less import directories

---
 lib/exe/css.php | 6 ++++++
 1 file changed, 6 insertions(+)

(limited to 'lib/exe')

diff --git a/lib/exe/css.php b/lib/exe/css.php
index f0bd24b43..bc0645400 100644
--- a/lib/exe/css.php
+++ b/lib/exe/css.php
@@ -173,6 +173,12 @@ function css_out(){
  */
 function css_parseless($css) {
     $less = new lessc();
+    $less->importDir[] = DOKU_INC;
+
+    if (defined('DOKU_UNITTEST')){
+        $less->importDir[] = TMP_DIR;
+    }
+
     try {
         return $less->compile($css);
     } catch(Exception $e) {
-- 
cgit v1.2.3


From de737055c55e54246de5000d601a089328c1af1c Mon Sep 17 00:00:00 2001
From: Christopher Smith 
Date: Tue, 5 Nov 2013 20:15:39 +0000
Subject: update url/file rewriting in css_loadfile() to support @import of
 less files

---
 lib/exe/css.php | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)

(limited to 'lib/exe')

diff --git a/lib/exe/css.php b/lib/exe/css.php
index bc0645400..3929b2d4b 100644
--- a/lib/exe/css.php
+++ b/lib/exe/css.php
@@ -403,12 +403,38 @@ function css_loadfile($file,$location=''){
     $css = io_readFile($file);
     if(!$location) return $css;
 
-    $css = preg_replace('#(url\([ \'"]*)(?!/|data:|http://|https://| |\'|")#','\\1'.$location,$css);
-    $css = preg_replace('#(@import\s+[\'"])(?!/|data:|http://|https://)#', '\\1'.$location, $css);
+    global $css_location;
+    global $css_current_dir;
+    $css_current_dir = preg_replace('#^('.DOKU_INC.(defined('DOKU_UNITTEST')?'|'.realpath(TMP_DIR) : '').')#','',dirname($file)).'/';
+    $css_location = $location;
+
+    $css = preg_replace_callback('#(url\( *)([\'"]?)(.*?)(\2)( *\))#','css_loadfile_callback',$css);
+    $css = preg_replace_callback('#(@import\s+)([\'"])(.*?)(\2)#','css_loadfile_callback',$css);
+#    $css = preg_replace_callback('#(url\([ \'"]*)(?!/|data:|http://|https://| |\'|")#','\\1'.$location,$css);
+#    $css = preg_replace_callback('#(@import\s+[\'"])(?!/|data:|http://|https://)#', '\\1'.$location, $css);
 
     return $css;
 }
 
+function css_loadfile_callback($match){
+    global $css_location;
+    global $css_current_dir;
+
+    if (preg_match('#^(/|data:|https?://)#',$match[3])) {
+        return $match[0];
+    }
+    else if (substr($match[3],-5) == '.less') {
+        if ($match[3]{0} != '/') {
+            $match[3] = $css_current_dir . $match[3];
+        }
+    }
+    else {
+        $match[3] = $css_location . $match[3];
+    }
+
+    return join('',array_slice($match,1));
+}
+
 /**
  * Converte local image URLs to data URLs if the filesize is small
  *
-- 
cgit v1.2.3


From 4eb5f931edaaabdd436f4c2802d0d293f8ef76cd Mon Sep 17 00:00:00 2001
From: Christopher Smith 
Date: Mon, 11 Nov 2013 22:03:58 +0000
Subject: fix sp. in comment

---
 lib/exe/css.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'lib/exe')

diff --git a/lib/exe/css.php b/lib/exe/css.php
index 3929b2d4b..948251440 100644
--- a/lib/exe/css.php
+++ b/lib/exe/css.php
@@ -436,7 +436,7 @@ function css_loadfile_callback($match){
 }
 
 /**
- * Converte local image URLs to data URLs if the filesize is small
+ * Convert local image URLs to data URLs if the filesize is small
  *
  * Callback for preg_replace_callback
  */
-- 
cgit v1.2.3


From 12ffbbc324be1f06ccfcff580f512990dca929b8 Mon Sep 17 00:00:00 2001
From: Christopher Smith 
Date: Mon, 11 Nov 2013 22:31:28 +0000
Subject: refactor to improve elegance

---
 lib/exe/css.php | 75 ++++++++++++++++++++++++++++++++++++++-------------------
 1 file changed, 50 insertions(+), 25 deletions(-)

(limited to 'lib/exe')

diff --git a/lib/exe/css.php b/lib/exe/css.php
index 948251440..9cde09545 100644
--- a/lib/exe/css.php
+++ b/lib/exe/css.php
@@ -399,40 +399,65 @@ function css_filetypes(){
  * given location prefix
  */
 function css_loadfile($file,$location=''){
-    if(!@file_exists($file)) return '';
-    $css = io_readFile($file);
-    if(!$location) return $css;
+    $css_file = new DokuCssFile($file);
+    return $css_file->load($location);
+}
 
-    global $css_location;
-    global $css_current_dir;
-    $css_current_dir = preg_replace('#^('.DOKU_INC.(defined('DOKU_UNITTEST')?'|'.realpath(TMP_DIR) : '').')#','',dirname($file)).'/';
-    $css_location = $location;
+class DokuCssFile {
 
-    $css = preg_replace_callback('#(url\( *)([\'"]?)(.*?)(\2)( *\))#','css_loadfile_callback',$css);
-    $css = preg_replace_callback('#(@import\s+)([\'"])(.*?)(\2)#','css_loadfile_callback',$css);
-#    $css = preg_replace_callback('#(url\([ \'"]*)(?!/|data:|http://|https://| |\'|")#','\\1'.$location,$css);
-#    $css = preg_replace_callback('#(@import\s+[\'"])(?!/|data:|http://|https://)#', '\\1'.$location, $css);
+    protected $filepath;
+    protected $location;
+    private   $relative_path = null;
 
-    return $css;
-}
+    public function __construct($file) {
+        $this->filepath = $file;
+    }
+
+    public function load($location='') {
+        if (!@file_exists($this->filepath)) return '';
 
-function css_loadfile_callback($match){
-    global $css_location;
-    global $css_current_dir;
+        $css = io_readFile($this->filepath);
+        if (!$location) return $css;
 
-    if (preg_match('#^(/|data:|https?://)#',$match[3])) {
-        return $match[0];
+        $this->location = $location;
+
+        $css = preg_replace_callback('#(url\( *)([\'"]?)(.*?)(\2)( *\))#',array($this,'replacements'),$css);
+        $css = preg_replace_callback('#(@import\s+)([\'"])(.*?)(\2)#',array($this,'replacements'),$css);
+
+        return $css;
     }
-    else if (substr($match[3],-5) == '.less') {
-        if ($match[3]{0} != '/') {
-            $match[3] = $css_current_dir . $match[3];
+
+    private function getRelativePath(){
+
+        if (is_null($this->relative_path)) {
+            $basedir = array(DOKU_INC);
+            if (defined('DOKU_UNITTEST')) {
+                $basedir[] = realpath(TMP_DIR);
+            }
+            $regex = '#^('.join('|',$basedir).')#';
+
+            $this->relative_path = preg_replace($regex, '', dirname($this->filepath));
         }
+
+        return $this->relative_path;
     }
-    else {
-        $match[3] = $css_location . $match[3];
-    }
 
-    return join('',array_slice($match,1));
+    public function replacements($match) {
+
+        if (preg_match('#^(/|data:|https?://)#',$match[3])) {
+            return $match[0];
+        }
+        else if (substr($match[3],-5) == '.less') {
+            if ($match[3]{0} != '/') {
+                $match[3] = $this->getRelativePath() . '/' . $match[3];
+            }
+        }
+        else {
+            $match[3] = $this->location . $match[3];
+        }
+
+        return join('',array_slice($match,1));
+    }
 }
 
 /**
-- 
cgit v1.2.3


From 47f862d1e038979f4d2dd5bb0c3eaaa9d1ee8fee Mon Sep 17 00:00:00 2001
From: Christopher Smith 
Date: Tue, 12 Nov 2013 23:37:38 +0000
Subject: Fix an issue with style.ini replacements values not having relative
 locations corrected, when those values are "url(...)".

Explanation:  In the change to the less css extension, variable
replacements now happen after the less/css files are processed
for correction of relative locations.
---
 lib/exe/css.php | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

(limited to 'lib/exe')

diff --git a/lib/exe/css.php b/lib/exe/css.php
index f0bd24b43..af7f9e4f1 100644
--- a/lib/exe/css.php
+++ b/lib/exe/css.php
@@ -271,7 +271,7 @@ function css_styleini($tpl) {
 
         // replacements
         if(is_array($data['replacements'])){
-            $replacements = array_merge($replacements, $data['replacements']);
+            $replacements = array_merge($replacements, css_fixreplacementurls($data['replacements'],$webbase));
         }
     }
 
@@ -288,7 +288,7 @@ function css_styleini($tpl) {
 
         // replacements
         if(is_array($data['replacements'])){
-            $replacements = array_merge($replacements, $data['replacements']);
+            $replacements = array_merge($replacements, css_fixreplacementurls($data['replacements'],$webbase));
         }
     }
 
@@ -306,7 +306,7 @@ function css_styleini($tpl) {
 
         // replacements
         if(is_array($data['replacements'])){
-            $replacements = array_merge($replacements, $data['replacements']);
+            $replacements = array_merge($replacements, css_fixreplacementurls($data['replacements'],$webbase));
         }
     }
 
@@ -316,6 +316,13 @@ function css_styleini($tpl) {
     );
 }
 
+function css_fixreplacementurls($replacements, $location) {
+    foreach($replacements as $key => $value) {
+        $replacements[$key] = preg_replace('#(url\([ \'"]*)(?!/|data:|http://|https://| |\'|")#','\\1'.$location,$value);
+    }
+    return $replacements;
+}
+
 /**
  * Prints classes for interwikilinks
  *
-- 
cgit v1.2.3


From 5381a7ee4e6527c7d6d6af67134ef92ba97f8745 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= 
Date: Wed, 13 Nov 2013 22:52:40 +0200
Subject: remove 'infos' misspelling

http://english.stackexchange.com/questions/117552/why-does-information-not-have-a-plural-form
---
 lib/exe/detail.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'lib/exe')

diff --git a/lib/exe/detail.php b/lib/exe/detail.php
index e3c81d877..cd3f362ad 100644
--- a/lib/exe/detail.php
+++ b/lib/exe/detail.php
@@ -6,7 +6,7 @@ require_once(DOKU_INC.'inc/init.php');
 $IMG  = getID('media');
 $ID   = cleanID($INPUT->str('id'));
 
-// this makes some general infos available as well as the info about the
+// this makes some general info available as well as the info about the
 // "parent" page
 $INFO = array_merge(pageinfo(),mediainfo());
 
-- 
cgit v1.2.3


From 1e2c59485b8396275abde11d047a4a42a4e4e335 Mon Sep 17 00:00:00 2001
From: Christopher Smith 
Date: Tue, 26 Nov 2013 19:39:05 +0000
Subject: improved comments for code associated with PR#407 & PR#408

---
 lib/exe/css.php | 39 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 37 insertions(+), 2 deletions(-)

(limited to 'lib/exe')

diff --git a/lib/exe/css.php b/lib/exe/css.php
index c2540cc03..c96dedd37 100644
--- a/lib/exe/css.php
+++ b/lib/exe/css.php
@@ -312,6 +312,11 @@ function css_styleini($tpl) {
     );
 }
 
+/**
+ * Amend paths used in replacement relative urls, refer FS#2879
+ *
+ * @author Chris Smith 
+ */
 function css_fixreplacementurls($replacements, $location) {
     foreach($replacements as $key => $value) {
         $replacements[$key] = preg_replace('#(url\([ \'"]*)(?!/|data:|http://|https://| |\'|")#','\\1'.$location,$value);
@@ -400,16 +405,29 @@ function css_loadfile($file,$location=''){
     return $css_file->load($location);
 }
 
+/**
+ *  Helper class to abstract loading of css/less files
+ *
+ *  @author Chris Smith 
+ */
 class DokuCssFile {
 
-    protected $filepath;
-    protected $location;
+    protected $filepath;             // file system path to the CSS/Less file
+    protected $location;             // base url location of the CSS/Less file
     private   $relative_path = null;
 
     public function __construct($file) {
         $this->filepath = $file;
     }
 
+    /**
+     * Load the contents of the css/less file and adjust any relative paths/urls (relative to this file) to be
+     * relative to the dokuwiki root: the web root (DOKU_BASE) for most files; the file system root (DOKU_INC)
+     * for less files.
+     *
+     * @param   string   $location   base url for this file
+     * @return  string               the CSS/Less contents of the file
+     */
     public function load($location='') {
         if (!@file_exists($this->filepath)) return '';
 
@@ -424,10 +442,17 @@ class DokuCssFile {
         return $css;
     }
 
+    /**
+     * Get the relative file system path of this file, relative to dokuwiki's root folder, DOKU_INC
+     *
+     * @return string   relative file system path
+     */
     private function getRelativePath(){
 
         if (is_null($this->relative_path)) {
             $basedir = array(DOKU_INC);
+
+            // during testing, files may be found relative to a second base dir, TMP_DIR
             if (defined('DOKU_UNITTEST')) {
                 $basedir[] = realpath(TMP_DIR);
             }
@@ -439,16 +464,26 @@ class DokuCssFile {
         return $this->relative_path;
     }
 
+    /**
+     * preg_replace callback to adjust relative urls from relative to this file to relative
+     * to the appropriate dokuwiki root location as described in the code
+     *
+     * @param  array    see http://php.net/preg_replace_callback
+     * @return string   see http://php.net/preg_replace_callback
+     */
     public function replacements($match) {
 
+        // not a relative url? - no adjustment required
         if (preg_match('#^(/|data:|https?://)#',$match[3])) {
             return $match[0];
         }
+        // a less file import? - requires a file system location
         else if (substr($match[3],-5) == '.less') {
             if ($match[3]{0} != '/') {
                 $match[3] = $this->getRelativePath() . '/' . $match[3];
             }
         }
+        // everything else requires a url adjustment
         else {
             $match[3] = $this->location . $match[3];
         }
-- 
cgit v1.2.3