dflydev / dflydev-fig-cookies

Cookies for PSR-7 HTTP Message Interface.
MIT License
224 stars 29 forks source link

added withUrlEncode function #27

Open edwardteach42 opened 7 years ago

edwardteach42 commented 7 years ago

Added new option: withUrlEncode(true);

This allows you to enable the php urlencod() on the cookie name and value if needed. This was necessary as most of my cookies are base64 encoded for AWS CloudFront and the equals symbol.

ajgarlag commented 7 years ago

Your PR is a BC break and the tests are broken. To avoid it, the urlEncode property should be true by default. You should add some tests for your added feature.

Anyway there are at least three points where you should skip the urlencode and urldecode calls:

https://github.com/dflydev/dflydev-fig-cookies/blob/ecd9e50a1c94905a4001dba8d2bca7f8b458aac9/src/Dflydev/FigCookies/SetCookie.php#L159-L161

https://github.com/dflydev/dflydev-fig-cookies/blob/ecd9e50a1c94905a4001dba8d2bca7f8b458aac9/src/Dflydev/FigCookies/Cookie.php#L61-L64

https://github.com/dflydev/dflydev-fig-cookies/blob/fc5a0260a3468dc41224af2305bfa36f7f9eb5fd/src/Dflydev/FigCookies/StringUtil.php#L20-L22