From 22377ae0260e78f2889bd27107e17ee98fa78763 Mon Sep 17 00:00:00 2001
From: Jaime Perez Crespo <jaime.perez@uninett.no>
Date: Wed, 22 Apr 2015 16:32:14 +0200
Subject: [PATCH] SimpleSAML_Utilities::resolvePath was moved incorrectly to
 \SimpleSAML\Utils\HTTP instead of \SimpleSAML\Utils\System. Fix that.

---
 lib/SimpleSAML/Utilities.php    |  6 ++--
 lib/SimpleSAML/Utils/HTTP.php   | 55 +-------------------------------
 lib/SimpleSAML/Utils/System.php | 56 +++++++++++++++++++++++++++++++++
 3 files changed, 60 insertions(+), 57 deletions(-)

diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php
index d8370acdc..5ad4754bd 100644
--- a/lib/SimpleSAML/Utilities.php
+++ b/lib/SimpleSAML/Utilities.php
@@ -462,10 +462,10 @@ class SimpleSAML_Utilities {
 
 
 	/**
-	 * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::resolvePath() instead.
+	 * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\System::resolvePath() instead.
 	 */
 	public static function resolvePath($path, $base = NULL) {
-		return \SimpleSAML\Utils\HTTP::resolvePath($path, $base);
+		return \SimpleSAML\Utils\System::resolvePath($path, $base);
 	}
 
 
@@ -539,7 +539,7 @@ class SimpleSAML_Utilities {
 
 		$globalConfig = SimpleSAML_Configuration::getInstance();
 		$base = $globalConfig->getPathValue('certdir', 'cert/');
-		return SimpleSAML_Utilities::resolvePath($path, $base);
+		return \SimpleSAML\Utils\System::resolvePath($path, $base);
 	}
 
 
diff --git a/lib/SimpleSAML/Utils/HTTP.php b/lib/SimpleSAML/Utils/HTTP.php
index 4a3637d43..c981f16e2 100644
--- a/lib/SimpleSAML/Utils/HTTP.php
+++ b/lib/SimpleSAML/Utils/HTTP.php
@@ -795,59 +795,6 @@ class HTTP
     }
 
 
-    /**
-     * Resolve a (possibly) relative path from the given base path.
-     *
-     * A path which starts with a '/' is assumed to be absolute, all others are assumed to be
-     * relative. The default base path is the root of the SimpleSAMPphp installation.
-     *
-     * @param string      $path The path we should resolve.
-     * @param string|null $base The base path, where we should search for $path from. Default value is the root of the
-     *     SimpleSAMLphp installation.
-     *
-     * @return string An absolute path referring to $path.
-     *
-     * @author Olav Morken, UNINETT AS <olav.morken@uninett.no>
-     */
-    public static function resolvePath($path, $base = null)
-    {
-        if ($base === null) {
-            $config = \SimpleSAML_Configuration::getInstance();
-            $base = $config->getBaseDir();
-        }
-
-        // remove trailing slashes from $base
-        while (substr($base, -1) === '/') {
-            $base = substr($base, 0, -1);
-        }
-
-        // check for absolute path
-        if (substr($path, 0, 1) === '/') {
-            // absolute path. */
-            $ret = '/';
-        } else {
-            // path relative to base
-            $ret = $base;
-        }
-
-        $path = explode('/', $path);
-        foreach ($path as $d) {
-            if ($d === '.') {
-                continue;
-            } elseif ($d === '..') {
-                $ret = dirname($ret);
-            } else {
-                if (substr($ret, -1) !== '/') {
-                    $ret .= '/';
-                }
-                $ret .= $d;
-            }
-        }
-
-        return $ret;
-    }
-
-
     /**
      * Resolve a (possibly relative) URL relative to a given base URL.
      *
@@ -929,7 +876,7 @@ class HTTP
             $tail = '';
         }
 
-        $dir = self::resolvePath($dir, $baseDir);
+        $dir = System::resolvePath($dir, $baseDir);
 
         return $baseHost.$dir.$tail;
     }
diff --git a/lib/SimpleSAML/Utils/System.php b/lib/SimpleSAML/Utils/System.php
index d613c0892..6a01c591b 100644
--- a/lib/SimpleSAML/Utils/System.php
+++ b/lib/SimpleSAML/Utils/System.php
@@ -18,6 +18,7 @@ class System
     const IRIX = 7;
     const SUNOS = 8;
 
+
     /**
      * This function returns the Operating System we are running on.
      *
@@ -54,6 +55,7 @@ class System
         return false;
     }
 
+
     /**
      * This function retrieves the path to a directory where temporary files can be saved.
      *
@@ -90,6 +92,60 @@ class System
         return $tempDir;
     }
 
+
+    /**
+     * Resolve a (possibly) relative path from the given base path.
+     *
+     * A path which starts with a '/' is assumed to be absolute, all others are assumed to be
+     * relative. The default base path is the root of the SimpleSAMLphp installation.
+     *
+     * @param string      $path The path we should resolve.
+     * @param string|null $base The base path, where we should search for $path from. Default value is the root of the
+     *     SimpleSAMLphp installation.
+     *
+     * @return string An absolute path referring to $path.
+     *
+     * @author Olav Morken, UNINETT AS <olav.morken@uninett.no>
+     */
+    public static function resolvePath($path, $base = null)
+    {
+        if ($base === null) {
+            $config = \SimpleSAML_Configuration::getInstance();
+            $base = $config->getBaseDir();
+        }
+
+        // remove trailing slashes from $base
+        while (substr($base, -1) === '/') {
+            $base = substr($base, 0, -1);
+        }
+
+        // check for absolute path
+        if (substr($path, 0, 1) === '/') {
+            // absolute path. */
+            $ret = '/';
+        } else {
+            // path relative to base
+            $ret = $base;
+        }
+
+        $path = explode('/', $path);
+        foreach ($path as $d) {
+            if ($d === '.') {
+                continue;
+            } elseif ($d === '..') {
+                $ret = dirname($ret);
+            } else {
+                if (substr($ret, -1) !== '/') {
+                    $ret .= '/';
+                }
+                $ret .= $d;
+            }
+        }
+
+        return $ret;
+    }
+
+
     /**
      * Atomically write a file.
      *
-- 
GitLab