S
S
Sergey Blokhin2011-09-23 15:18:47
PHP
Sergey Blokhin, 2011-09-23 15:18:47

Proper handling of "+" in a GET request?

The project is made in PHP.
There is a link like server.com/index.php?email=name%[email protected] Following
such a link causes the browser (Firefox) to convert %2B to "+".
Next, the server receives a GET request in PHP as "name [email protected]".
That is, the browser, server, or PHP treats the "+" character as a space.
I need to have "[email protected]" in the GET variable, not "name [email protected]".
You can, of course, replace the space with "+" already in the code, but maybe there is a more correct solution to this problem?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
T
Troytft, 2011-09-23
@Troytft

encodeURIComponent(text)

T
temaHT, 2011-09-23
@temaHT

Are you sure it's the browser that converts? In theory, if there really is such a link, then [email protected] should just come to the script. It is possible that somewhere at the stage of link formation, an incorrect operation occurs.

F
Fedcomp, 2011-09-24
@Fedcomp

I had this problem with mod_rewrite in apache. Solved by double escaping url_encode() (and double decoding, respectively)

A
Anatoly, 2011-09-23
@taliban

$_SERVER['REQUEST_URI'] what's in there? maybe you have a tricky filter there

S
Sergey Beresnev, 2011-09-24
@sectus

Here are suggested solutions for this: www.dracos.co.uk/code/apache-rewrite-problem/
You can also try flag b , but as far as I understand, there will be a reverse situation - the space will turn into '+'.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question