How to pass the "+" signal using GET?

Asked

Viewed 67 times

2

I need to send a parameter GET which is encrypted in AES but in the hash sometimes comes a + and in sending the browser interprets this + separating the hash.

Example of the URL:

http://meusite/rota/?empresa=U2FsdGVkX1+T0MCaQbe7CRkz6jsZQoznI80UCEK6s0I=

How do I get the company parameter:

U2FsdGVkX1 T0MCaQbe7CRkz6jsZQoznI80UCEK6s0I=

how can I treat this GET to receive the hash without separation?

1 answer

3


Change the sign of + for %2B, if you are generating the link via Javascript you can do so:

var resultado = encodeURIComponent("U2FsdGVkX1+T0MCaQbe7CRkz6jsZQoznI80UCEK6s0I=");

console.log(resultado);

If you are generating via PHP you can do so:

<a href="foo/?empresa=<?php echo rawurlencode('U2FsdGVkX1+T0MCaQbe7CRkz6jsZQoznI80UCEK6s0I='); ?>">link</a>

In HTML basically that would be:

<a href="foo/?empresa=U2FsdGVkX1%2BT0MCaQbe7CRkz6jsZQoznI80UCEK6s0I=">link</a>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.