Bug Report
| Information |
Description |
| Package |
uri-components |
| Version |
2.4.1 |
| PHP version |
8.1.2 |
| OS Platform |
Ubuntu |
Summary
I am trying to send phone numbers as query string parameters to communicate with a REST API and the request is failing because + is not encoded to %2B.
Standalone code, or other way to reproduce the problem
$queryPairs = [
["phone_number", "+18001231234"],
["special_characetrs", " /+t!q_"]
];
$queryString = QueryString::build($queryPairs, '&', PHP_QUERY_RFC1738);
print("League\URI PHP_QUERY_RFC1738 $queryString\n");
$queryString = QueryString::build($queryPairs, '&', PHP_QUERY_RFC3986);
print("League\URI PHP_QUERY_RFC3986 $queryString\n");
Expected result
The + character should be percent-encoded.
Actual result
League\URI PHP_QUERY_RFC1738 phone_number=%2B18001231234&special_characetrs=+%2F%2Bt%21q_
League\URI PHP_QUERY_RFC3986 phone_number=+18001231234&special_characetrs=%20/+t!q_
Bug Report
Summary
I am trying to send phone numbers as query string parameters to communicate with a REST API and the request is failing because
+is not encoded to%2B.Standalone code, or other way to reproduce the problem
Expected result
The
+character should be percent-encoded.Actual result