Skip to content

Commit 2c4ea3d

Browse files
author
Martin Brecht-Precht
committedJul 12, 2016
Added URL encoding to the query parameters on build query string method.
1 parent b45dd09 commit 2c4ea3d

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed
 

‎src/QueryParameter.php

+8
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ public function getValue()
6363
return $this->value;
6464
}
6565

66+
/**
67+
* @return string
68+
*/
69+
public function getEscapedValue()
70+
{
71+
return urlencode((string)$this->value);
72+
}
73+
6674
/**
6775
* @param mixed $value
6876
* @return $this

‎src/QueryParameterInterface.php

+5
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ public function setKey($key);
3434
*/
3535
public function getValue();
3636

37+
/**
38+
* @return string
39+
*/
40+
public function getEscapedValue();
41+
3742
/**
3843
* @param mixed $value
3944
* @return $this

‎src/Url.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function buildQueryString()
134134
}
135135
$queryParameters = array();
136136
foreach ($this->getQueryParameters() as $queryParameter) {
137-
$queryParameters[] = $queryParameter->getKey() . '=' . $queryParameter->getValue();
137+
$queryParameters[] = $queryParameter->getKey() . '=' . $queryParameter->getEscapedValue();
138138
}
139139
return implode(self::URL_QUERY_SEPARATOR, $queryParameters);
140140
}

0 commit comments

Comments
 (0)