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

FormFilter does not adjust Content-Length header

Open
#3,972 0 comments 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
FormFilter can recreate produce body bigger than original but Content-Length header is not changed.
Any other processing may fail because it may read body up to Content-Length trimming it in the process.

Sample
Example is exlamation mark character.

When sending x-www-form-urlencoded form a browser it will not encode "!" into %21.
It will count this character as 1 byte

However FormFilter will encode the character here increasing the output by 2 bytes

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 in spring-cloud-gateway-server-webmvc/src/main/java/org/springframework/cloud/gateway/server/mvc/filter/FormFilter.java around the linked line where the form body is recreated. Reproduce the x-www-form-urlencoded case with an exclamation mark and verify that the Content-Length header matches the regenerated body length. Done means downstream processing can read the complete body without truncation.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.