Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

330
Visualizações
What is the point of rawurldecode() and urldecode() when the browser apparently does it automatically?

I can't tell you how many hours of my life I've wasted on these kinds of idiotic errors.

I'm basically constructing a URL such as: https://example.com/?test=' . urlencode('meow+foo@gmail.com');

Then, I display it from the URL, like this: echo urldecode($_GET['test']);

And then it shows: meow foo@gmail.com.

Ugh.

If I instead fo this: echo $_GET['test'];

I get: meow+foo@gmail.com.

(Naturally, echoing a GET variable like that is insanity, so I would of course do htmlspecialchars around it in reality. But that's not the point I'm making here.)

So, since browsers (or something) is clearly making this "translation" or "decoding" automatically, doing it again messes it up by removing certain characters, in this case the "+" (plus). Which leads me to believe that I'm not supposed to use urldecode/rawurldecode at all.

But then why do they exist?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

So when would one ever want to use them

I recently had a case where we added triggers to an S3 bucket which were being picked up by a Lambda function and sent via a HTTP request to an API endpoint.

If the path of the file on S3 was multiword, it would replace the space with a + at which point it would break our code because tecnically the path is incorrect.

Once you run it through urldecode it becomes a valid path because as per the docs:

Decodes any %## encoding in the given string. Plus symbols ('+') are decoded to a space character.

That would be a valid use case for this function as no browser is involved. Just background processes/requests.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda