-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
+ not encoded in query string when using PHP_QUERY_RFC3986 #109
Comments
This is expected behaviour the |
It's possible the REST API is not RFC compliant or using some old RFC so I may need to find a work around to interoperate with it in that case. |
Encoding characters in URL is tricky because depending on the consuming client and its implementor and the year it was implemented and the language it gets complex and overly complicated indeed. And the amount of different RFC does not help either |
Thinking about this further, when echo 'RFC1738: ', http_build_query(['key' => '+ '], encoding_type: PHP_QUERY_RFC1738), "\n";
echo 'RFC3986: ', http_build_query(['key' => '+ '], encoding_type: PHP_QUERY_RFC3986), "\n"; Output:
|
@nyamsprod I believe this is a bug, as @trowski already mentioned. We switched to |
From my understanding, any reserved characters in RFC3986 should be encoded unless they are known to have semantic meaning in a URL schema. This may require passing another parameter designating which characters to exclude from encoding. Something that can maybe be changed before v7? |
@trowski v7 is already out ... since yesterday. Let's see if can fix that issue and backport it into v6 if needed. |
Oh, apologies, I should have checked. I'd consider this a bugfix anyway, and adding a parameter with a default should be no issue. Backporting to v6 would be fantastic. |
@
So do I this is just a fix ... just need to be applied correctly |
The fix has already been shipped on V2 it will be shipped in V7 later today |
Sorry for the delay, my weekend was rather busy. I'm not sure if the issue is limited to just Encoding |
@trowski no problem These are just fix to improve encoding so I can still release a new fix if needed and that's also why I did not release the fix yet for v7. I stumble on this article https://www.456bereastreet.com/archive/201008/what_characters_are_allowed_unencoded_in_query_strings/ which is using the same logic that I did for not converting the |
I just tried the implementation from Guzzle and it behave like the package did before the fix (string) Uri::withQueryValue(new Uri('https://example.com'), 'key', " /+t!q_");
// displays "https://example.com?key=%20/+t!q_" sub-delims characters are not encoded. |
7.1.0 is released with the fix |
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
The text was updated successfully, but these errors were encountered: