Percent-Encoding Pitfalls: Double Encoding, Plus vs %20, and Delimiters
URL Tools

Percent-Encoding Pitfalls: Double Encoding, Plus vs %20, and Delimiters

Site DeveloperSite Developer
2025-12-25

Percent-Encoding Pitfalls: Double Encoding, Plus vs %20, and Delimiters

Quick answer: Most URL encoding bugs come from decoding the wrong layer. If you see %25, you likely have double encoding. If plus turns into space unexpectedly, you may be mixing form encoding rules with normal URLs. Use /url-decoder to inspect and decode step-by-step.

Double encoding: how to recognize it quickly

Double encoding means a percent sign was encoded as data. Because % becomes %25, you will see many %25 sequences. This commonly happens when a value is encoded, then encoded again while building another URL. It is especially common with redirect URLs stored inside query parameters.

Fast recognition tips:

  • %252F often indicates an encoded slash (/).
  • %253A often indicates an encoded colon (:).
  • If decoding once produces many %XX sequences, you likely need a second pass.

Safe approach:

  1. Decode one layer.
  2. Re-check whether the result is now readable.
  3. Stop as soon as the intent is clear.
  4. Do not decode more layers “just in case”.

Plus vs %20: form encoding is not the same as URL encoding

In HTML form encoding (application/x-www-form-urlencoded), plus represents space. In a normal URL path or query value, plus is just a plus unless your parser applies form rules. This causes subtle bugs when different components interpret the same URL differently.

What to do:

  • Confirm whether the input came from a form post, a browser location bar, or a server redirect.
  • Use a single library to parse and decode consistently across services.
  • If you sign URLs, sign the exact original string, not a decoded variant.

Common pitfalls:

  • Turning literal plus signs into spaces and breaking identifiers.
  • Treating %20 and plus as always equivalent when they are not.
  • Mixing multiple parsers with different defaults across microservices.

Key takeaways

  • Definition: Plus vs %20: form encoding is not the same as URL encoding clarifies what the input represents and what the output should mean.
  • Why it matters: correct interpretation prevents downstream bugs and incorrect conclusions.
  • Validation: confirm assumptions before changing formats, units, or encodings.
  • Repeatability: use the same steps each time so results are consistent across environments.

Common pitfalls

  • Mistake: skipping validation and trusting the first output you see in Plus vs %20: form encoding is not the same as URL encoding.
  • Mistake: mixing formats or layers (for example, decoding the wrong field or using the wrong unit).
  • Mistake: losing the original input, making it impossible to reproduce the issue.

Quick checklist

  1. Identify the exact input format and whether it is nested or transformed multiple times.
  2. Apply the minimal transformation needed to make it readable.
  3. Validate the result (structure, encoding, expected markers) before acting on it.
  4. Stop as soon as the result is clear; avoid over-decoding or over-normalizing.

Reserved characters and delimiters (why order matters)

Reserved characters separate parts of a URL. The most important ones are ?, &, =, #, and /. If these appear as data, they must be percent-encoded. If you decode too early, you can accidentally create new delimiters.

Debug checklist:

  1. Identify which part is being decoded (path, query key, query value, fragment).
  2. Decode only that part, not the entire URL.
  3. Ensure delimiters remain where you expect them.
  4. If a value contains a nested URL, keep it encoded as data inside the outer URL.

Key takeaways

  • Definition: Reserved characters and delimiters (why order matters) clarifies what the input represents and what the output should mean.
  • Why it matters: correct interpretation prevents downstream bugs and incorrect conclusions.
  • Validation: confirm assumptions before changing formats, units, or encodings.
  • Repeatability: use the same steps each time so results are consistent across environments.

Common pitfalls

  • Mistake: skipping validation and trusting the first output you see in Reserved characters and delimiters (why order matters).
  • Mistake: mixing formats or layers (for example, decoding the wrong field or using the wrong unit).
  • Mistake: losing the original input, making it impossible to reproduce the issue.

Quick checklist

  1. Identify the exact input format and whether it is nested or transformed multiple times.
  2. Apply the minimal transformation needed to make it readable.
  3. Validate the result (structure, encoding, expected markers) before acting on it.
  4. Stop as soon as the result is clear; avoid over-decoding or over-normalizing.

Common mistakes and quick fixes

Mistake: Encoding the full URL twice during redirect construction. Fix: Encode only the nested value, not the entire outer URL.

Mistake: Decoding a signed URL before verifying it. Fix: Verify the signature on the original encoded bytes.

Mistake: Copying URLs from logs that were truncated or escaped. Fix: Capture the raw URL at the boundary (HTTP request) and keep it unchanged.

Key takeaways

  • Definition: Common mistakes and quick fixes clarifies what the input represents and what the output should mean.
  • Why it matters: correct interpretation prevents downstream bugs and incorrect conclusions.
  • Validation: confirm assumptions before changing formats, units, or encodings.
  • Repeatability: use the same steps each time so results are consistent across environments.

Common pitfalls

  • Mistake: skipping validation and trusting the first output you see in Common mistakes and quick fixes.
  • Mistake: mixing formats or layers (for example, decoding the wrong field or using the wrong unit).
  • Mistake: losing the original input, making it impossible to reproduce the issue.

Quick checklist

  1. Identify the exact input format and whether it is nested or transformed multiple times.
  2. Apply the minimal transformation needed to make it readable.
  3. Validate the result (structure, encoding, expected markers) before acting on it.
  4. Stop as soon as the result is clear; avoid over-decoding or over-normalizing.

FAQ

How many times should I decode?

As few as possible. Decode one layer at a time. Stop when the string is readable and the structure makes sense.

Why do signatures fail after decoding?

Because the signature was computed over the original encoded string. Any decoding or normalization changes the bytes and invalidates the signature.

What should I do if the output still looks encoded?

Decode step-by-step. If you still see obvious markers, the data is likely nested or transformed multiple times.

What is the safest way to avoid bugs?

Keep the original input, change one thing at a time, and validate after each step so the fix is reproducible.

Should I use the decoded value in production requests?

Usually no. Decode for inspection and debugging, but send the original encoded form unless the protocol expects decoded text.

Why does it work in one environment but not another?

Different environments often have different settings (time zones, keys, encoders, parsing rules). Compare a known-good sample side-by-side.

References

Key takeaways

  • Definition: References clarifies what the input represents and what the output should mean.
  • Why it matters: correct interpretation prevents downstream bugs and incorrect conclusions.
  • Validation: confirm assumptions before changing formats, units, or encodings.
  • Repeatability: use the same steps each time so results are consistent across environments.

Common pitfalls

  • Mistake: skipping validation and trusting the first output you see in References.
  • Mistake: mixing formats or layers (for example, decoding the wrong field or using the wrong unit).
  • Mistake: losing the original input, making it impossible to reproduce the issue.

Quick checklist

  1. Identify the exact input format and whether it is nested or transformed multiple times.
  2. Apply the minimal transformation needed to make it readable.
  3. Validate the result (structure, encoding, expected markers) before acting on it.
  4. Stop as soon as the result is clear; avoid over-decoding or over-normalizing.
Back to Blog

Found this helpful?

Try Our Tools