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

AddRequestParameter double encodes parameter value

Open
#3,466 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Describe the bug
AddRequestParameter encodes the already-encoded value when other parameter is encoded.

There is an remote endpoint which has two request parameters(Say, a and b) which each may need to be url-encoded.

Within my route, I'm intending putting the b parameter's value.

Per, #2717, I configured the b parameter's value as url-encoded.

When sending a with an ascii value, it works.

When sending a with an url-encoded value, the b parameter's value is double-encoded.

# application.yaml

spring:
  cloud:
    gateway:
      routes:
        filters:
          - AddRequestParameter=b, %2F
CLIENT                  GATEWAY
--------------------------------------------------
a=%2F                   a=%2F&b=%2F   OK
a=a                     a=a&b=%252F   NOT OK

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 at the AddRequestParameter filter entry point and reproduce the issue with the application.yaml route configuration shown here, testing both encoded and ASCII values for parameter a. Trace how the filter handles the configured b value; done means an already URL-encoded b value is not double-encoded when a is ASCII.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.