spring-cloud / spring-cloud/spring-cloud-gateway

Double encoded URLs

Open
#2,065 32 comments 17 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Java
Stars
4.9k
Forks
3.5k
Avg merge
20h 57m
Merged PRs (30d)
8

Description

Describe the bug
After migrating to cloud 2020.0.0-M6 from Hoxton.SR8 I started to have problems with double encoded URLs. It most probably only affects URL containing multiple = charactors in one query parameter. Problem most probably is that ServerWebExchangeUtils#containsEncodedParts reports false - taking URL as not encoded.

Sample

Exception is trapped in:

catch (IllegalArgumentException ignore) {
  if (log.isTraceEnabled()) {
    log.trace("Error in containsEncodedParts", ignore);
  }
}

java.lang.IllegalArgumentException: Invalid character '=' for QUERY_PARAM in "key==%22value%22"

For URL:

/filter?query=key=="value"&page=0&size=30

This "kind" of URL should be valid and is used by https://github.com/jirutka/rsql-parser or FIQL (https://tools.ietf.org/html/draft-nottingham-atompub-fiql-00#section-4)

Seems the validation is too strict. As it cannot be replaced with custom implementation, it would essentially mean rewriting the RouteToRequestUrlFilter filter (and potentially others, that use ServerWebExchangeUtils#containsEncodedParts).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with ServerWebExchangeUtils#containsEncodedParts and the RouteToRequestUrlFilter, reproducing the reported URL containing multiple '=' characters in one query parameter. Trace the exception path and verify that valid query parameters are handled without double encoding or being treated as unencoded.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.