summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/SimpleSAML/Module.php2
-rw-r--r--lib/SimpleSAML/Utilities.php46
-rw-r--r--lib/SimpleSAML/Utils/HTTP.php42
3 files changed, 46 insertions, 44 deletions
diff --git a/lib/SimpleSAML/Module.php b/lib/SimpleSAML/Module.php
index b5d8f02..829fa7b 100644
--- a/lib/SimpleSAML/Module.php
+++ b/lib/SimpleSAML/Module.php
@@ -157,7 +157,7 @@ class SimpleSAML_Module {
$url = SimpleSAML_Utilities::getBaseURL() . 'module.php/' . $resource;
if (!empty($parameters)) {
- $url = SimpleSAML_Utilities::addURLparameter($url, $parameters);
+ $url = \SimpleSAML\Utils\HTTP::addURLParameters($url, $parameters);
}
return $url;
}
diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php
index a0dab57..334f584 100644
--- a/lib/SimpleSAML/Utilities.php
+++ b/lib/SimpleSAML/Utilities.php
@@ -252,48 +252,10 @@ class SimpleSAML_Utilities {
/**
- * Add one or more query parameters to the given URL.
- *
- * @param $url The URL the query parameters should be added to.
- * @param $parameter The query parameters which should be added to the url. This should be
- * an associative array. For backwards comaptibility, it can also be a
- * query string representing the new parameters. This will write a warning
- * to the log.
- * @return The URL with the new query parameters.
- */
- public static function addURLparameter($url, $parameter) {
-
- /* For backwards compatibility - allow $parameter to be a string. */
- if(is_string($parameter)) {
- /* Print warning to log. */
- $backtrace = debug_backtrace();
- $where = $backtrace[0]['file'] . ':' . $backtrace[0]['line'];
- SimpleSAML_Logger::warning(
- 'Deprecated use of SimpleSAML_Utilities::addURLparameter at ' . $where .
- '. The parameter "$parameter" should now be an array, but a string was passed.');
-
- $parameter = self::parseQueryString($parameter);
- }
- assert('is_array($parameter)');
-
- $queryStart = strpos($url, '?');
- if($queryStart === FALSE) {
- $oldQuery = array();
- $url .= '?';
- } else {
- $oldQuery = substr($url, $queryStart + 1);
- if($oldQuery === FALSE) {
- $oldQuery = array();
- } else {
- $oldQuery = self::parseQueryString($oldQuery);
- }
- $url = substr($url, 0, $queryStart + 1);
- }
-
- $query = array_merge($oldQuery, $parameter);
- $url .= http_build_query($query, '', '&');
-
- return $url;
+ * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::addURLParameters() instead.
+ */
+ public static function addURLparameter($url, $parameters) {
+ return \SimpleSAML\Utils\HTTP::addURLParameter($url, $parameters);
}
diff --git a/lib/SimpleSAML/Utils/HTTP.php b/lib/SimpleSAML/Utils/HTTP.php
index d501162..bf7ac0c 100644
--- a/lib/SimpleSAML/Utils/HTTP.php
+++ b/lib/SimpleSAML/Utils/HTTP.php
@@ -66,6 +66,46 @@ class HTTP
/**
+ * Add one or more query parameters to the given URL.
+ *
+ * @param string $url The URL the query parameters should be added to.
+ * @param array $parameters The query parameters which should be added to the url. This should be an associative
+ * array.
+ *
+ * @return string The URL with the new query parameters.
+ * @throws \SimpleSAML_Error_Exception If $url is not a string or $parameters is not an array.
+ *
+ * @author Andreas Solberg, UNINETT AS <andreas.solberg@uninett.no>
+ * @author Olav Morken, UNINETT AS <olav.morken@uninett.no>
+ */
+ public static function addURLParameters($url, $parameters)
+ {
+ if (!is_string($url) || !is_array($parameters)) {
+ throw new \SimpleSAML_Error_Exception('Invalid input parameters.');
+ }
+
+ $queryStart = strpos($url, '?');
+ if ($queryStart === false) {
+ $oldQuery = array();
+ $url .= '?';
+ } else {
+ $oldQuery = substr($url, $queryStart + 1);
+ if ($oldQuery === false) {
+ $oldQuery = array();
+ } else {
+ $oldQuery = self::parseQueryString($oldQuery);
+ }
+ $url = substr($url, 0, $queryStart + 1);
+ }
+
+ $query = array_merge($oldQuery, $parameters);
+ $url .= http_build_query($query, '', '&');
+
+ return $url;
+ }
+
+
+ /**
* Retrieve the port number from $_SERVER environment variables.
*
* @return string The port number prepended by a colon, if it is different than the default port for the protocol
@@ -107,7 +147,7 @@ class HTTP
public static function parseQueryString($query_string)
{
if (!is_string($query_string)) {
- throw new \SimpleSAML_Error_Exception('Invalid input parameters');
+ throw new \SimpleSAML_Error_Exception('Invalid input parameters.');
}
$res = array();