refactor: Improve Forwarded header field parsing - #7126
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #7126 +/- ##
=======================================
Coverage 82.1% 82.1%
=======================================
Files 1010 1010
Lines 76064 76070 +6
Branches 7375 7370 -5
=======================================
+ Hits 62470 62481 +11
+ Misses 13594 13589 -5
🚀 New features to boost your workflow:
|
4b5cf46 to
17f5112
Compare
17f5112 to
803376b
Compare
803376b to
e11cc5d
Compare
There was a problem hiding this comment.
We can add tokenizing per RFC 7239 grammar instead of patching the std::search loop:
- Split on
,boundaries (forwarded-element list) - Trim white-spaces
- Split each element on
;(parameter list) - Match directive name case-insensitively
The current approach (search + boundary-check + retry loop) works for the known cases, but it's fragile — any future directive containing the substring "for=" would require another boundary fix. A proper tokenizer eliminates this class of bugs entirely and is only marginally more code. Why do the same fix twice across two branches without addressing the structural weakness?
godexsoft
left a comment
There was a problem hiding this comment.
I'd recommend to address @pratikmankawde comment in a follow up PR 👍
|
@lmaisons is this ready to merge? |
Improve the Forwarded header field parsing in
forwardedFor():for=is only matched at the start of the value or after a field delimiter per RFC 7239