mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-23 13:54:26 +02:00
Web\UrlParams: add() and set() should encode...
...while there is now a addEncoded function, mostly for internal use. refs #6699
This commit is contained in:
parent
217595dc15
commit
344909dfcd
@ -114,6 +114,18 @@ class UrlParams
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function addEncoded($param, $value = true)
|
||||||
|
{
|
||||||
|
$this->params[] = array($param, $this->cleanupValue($value));
|
||||||
|
$this->indexLastOne();
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function urlEncode($value)
|
||||||
|
{
|
||||||
|
return rawurlencode((string) $value);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the given parameter with the given value
|
* Add the given parameter with the given value
|
||||||
*
|
*
|
||||||
@ -127,9 +139,7 @@ class UrlParams
|
|||||||
*/
|
*/
|
||||||
public function add($param, $value = true)
|
public function add($param, $value = true)
|
||||||
{
|
{
|
||||||
$this->params[] = array($param, $this->cleanupValue($value));
|
return $this->addEncoded($this->urlEncode($param), $this->urlEncode($value));
|
||||||
$this->indexLastOne();
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -198,7 +208,7 @@ class UrlParams
|
|||||||
*/
|
*/
|
||||||
public function unshift($param, $value)
|
public function unshift($param, $value)
|
||||||
{
|
{
|
||||||
array_unshift($this->params, array($param, $this->cleanupValue($value)));
|
array_unshift($this->params, array($this->urlEncode($param), $this->urlEncode($value)));
|
||||||
$this->reIndexAll();
|
$this->reIndexAll();
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -224,7 +234,10 @@ class UrlParams
|
|||||||
unset($this->params[$remove]);
|
unset($this->params[$remove]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->params[$this->index[$param][0]] = array($param, $this->cleanupValue($value));
|
$this->params[$this->index[$param][0]] = array(
|
||||||
|
$this->urlEncode($param),
|
||||||
|
$this->urlEncode($this->cleanupValue($value))
|
||||||
|
);
|
||||||
$this->reIndexAll();
|
$this->reIndexAll();
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@ -303,10 +316,10 @@ class UrlParams
|
|||||||
protected function parseQueryStringPart($part)
|
protected function parseQueryStringPart($part)
|
||||||
{
|
{
|
||||||
if (strpos($part, '=') === false) {
|
if (strpos($part, '=') === false) {
|
||||||
$this->add($part, true);
|
$this->addEncoded($part, true);
|
||||||
} else {
|
} else {
|
||||||
list($key, $val) = preg_split('/=/', $part, 2);
|
list($key, $val) = preg_split('/=/', $part, 2);
|
||||||
$this->add($key, $val);
|
$this->addEncoded($key, $val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user