Skip to content

Protect against {boolean}.to_i raising on invalid stale-while-revalidate cache control directives - #144

Merged
georgeguimaraes merged 1 commit into
sourcelevel:masterfrom
matthutchinson:safer-stale-while-revalidate-parsing
Sep 15, 2026
Merged

georgeguimaraes merged 1 commit into
sourcelevel:masterfrom
matthutchinson:safer-stale-while-revalidate-parsing

Conversation

@matthutchinson

Copy link
Copy Markdown
Contributor

Invalid cache control directives for stale-while-revalidate are raising here when we attempt to parse the integer value.

Eg. an invalid cache-control directive such as this

public, max-age=60, stale-while-revalidate

The gem converts directives without values to true here.

This PR will allow the gem to ignore these invalid values (see spec), and prevent this error from raising;

[NoMethodError] undefined method 'to_i' for true

Added tests to verify behaviour.

@georgeguimaraes
georgeguimaraes merged commit bb38ceb into sourcelevel:master Sep 15, 2026
10 checks passed
@georgeguimaraes

Copy link
Copy Markdown
Member

tks!! <3

georgeguimaraes added a commit that referenced this pull request Sep 15, 2026
A bare max-age or s-maxage parses as true and calling to_i on it raised NoMethodError, the same crash #144 fixed for stale-while-revalidate. Read all three integer directives through one helper that treats a valueless directive as absent, including in normalize_max_ages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants