Repository navigation
Conversation
Previously, HTTPProxyServer#split_field used f.split(/,\s+/), which
assumed at least one space character after each comma. Under RFC 9110
Section 5.6.1.2 and Section 7.6.1, comma-separated list values allow
optional whitespace (OWS = *( SP / HTAB )) before and after the comma,
including zero whitespace (e.g. 'Connection: close,keep-alive') or
spaces before commas ('Connection: close , keep-alive').
This change splits on commas directly, strips surrounding whitespace,
and discards empty tokens, correctly normalizing all compliant
hop-by-hop header tokens.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR updates
HTTPProxyServer#split_fieldinlib/webrick/httpproxy.rbto conform with RFC 9110 §5.6.1.2 and §7.6.1 optional whitespace (OWS) rules.Context & Motivation
In
WEBrick::HTTPProxyServer, hop-by-hop headers listed in theConnectionheader (or related fields) are extracted viasplit_field:The regex
,\s+required at least one whitespace character after each comma. Under RFC 9110 (and earlier RFC 7230 §3.2.2), comma-separated list syntax allows optional whitespace before and after commas:Connection: close,keep-alive(zero whitespace)Connection: close , keep-alive(whitespace before comma)Connection: close\t,\tkeep-alive(tab characters)When an intermediary or client sends
Connection: close,keep-alivewithout spaces,split_fieldwould fail to tokenize the header into individual tokens, leaving"close,keep-alive"as an unseparated token and preventing matching hop-by-hop headers from being stripped.Changes
split_fieldto split on commas (','), strip leading and trailing whitespace on each token (.strip.downcase), and reject empty elements.test/webrick/test_httpproxy.rbcovering standard whitespace variants (tabs, spaces before/after, zero spaces, trailing commas).