1

I send requests from ios and android to some PHP server and some params in GET request are wrongly decoded.

request: http://myserver.com/path?email=john+doe

$_GET['email'] == 'john doe' instead of 'john+doe'
$this->request->get('email') == 'john doe' instead of 'john+doe'

Obviously php (I'm using phalcon) is using urldecode and replace + with 1 space.

How can avoid this? Can I change the type of enconding and "Content-Type" header accordingly?

Alexandru Circus
  • 5,478
  • 7
  • 52
  • 89
  • Possible duplicate of [URLs and plus signs](https://stackoverflow.com/questions/1005676/urls-and-plus-signs) – eisbehr May 23 '18 at 11:02

2 Answers2

2

are wrongly decoded

They are correctly decoded.

Can I change the type of enconding and "Content-Type" header accordingly?

No. The Content-Type header describes the format of the request body, not the query string.

You should encode the data in the query string correctly in the first place.

A + sign should be represented as %2B.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
2

If you really needed the '+' sign in the PHP file, you may need to have the '+' as '%2B'.

There is nothing wrong in reading the values which you mentioned.

Anil Kumar
  • 94
  • 4