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

353
Visualizações
URLDecoder is converting '+' into space

I have a hash key in one of my query params which can have + char with other special chars. The issue is when this URL is getting decoded URLDecoder converts + char into space. Is there a way we can enforce URLDecoder not to convert '+' into space.

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

0

Do this on your string before decoding:

String plusEncoded = yourString.replaceAll("\\+", "%2b")

The decoder will then show + where it should've been

over 4 years ago · Santiago Trujillo Relatório

0

According to HTML URL Encoding Reference:

URLs cannot contain spaces. URL encoding normally replaces a space with a plus (+) sign or with %20.

and + sign itself must be encoded with %2B. So if you want to pass your hash as a GET parameter in URL, you should replace plus signs with %2B in your hash. Do not replace every + in the entire URL because you might ruin other string parameters which suppose to contain spaces.

over 4 years ago · Santiago Trujillo Relatório

0

There is a bug reference similar to this issue, and it's closed as "not an issue". Here I quote what the Assignee had told:

The Java API documentation at https://docs.oracle.com/javase/8/docs/api/java/net/URL.html clearly states that "The URLEncoder and URLDecoder classes can also be used, but only for HTML form encoding, which is not the same as the encoding scheme defined in RFC2396." . This means that it is not meant for URL encoding and will cause issues with spaces and plus signs in the path. Using URL or URI classes to construct the url will give expected results.

URL url = new URL(input);
System.out.println(url.toString()); //outputs http://www.example.com/some+thing

Reference: https://bugs.openjdk.java.net/browse/JDK-8179507

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