Skip to content

Allow configuring or disabling max cookie size check#1109

Merged
davidism merged 3 commits intopallets:masterfrom
davidism:max-cookie-size
Apr 18, 2017
Merged

Allow configuring or disabling max cookie size check#1109
davidism merged 3 commits intopallets:masterfrom
davidism:max-cookie-size

Conversation

@davidism
Copy link
Copy Markdown
Member

Continue #780

  • use arg instead of const for dump_cookie max_size
  • add max_cookie_size attr to BaseResponse
  • add changelog

@davidism davidism self-assigned this Apr 18, 2017
add max_cookie_size attr to BaseResponse
add changelog for #780
Comment thread werkzeug/wrappers.py
supported by all browsers.
"""
self.headers.add('Set-Cookie', dump_cookie(key,
value=value,

This comment was marked as off-topic.

@untitaker
Copy link
Copy Markdown
Contributor

LGTM, might need a testcase for custom values though

@davidism
Copy link
Copy Markdown
Member Author

The error is slightly confusing because you can pass 4093 bytes as the value and still get the error, since the options are added to the payload. I don't think we need to change it, just pointing it out.

@untitaker
Copy link
Copy Markdown
Contributor

untitaker commented Apr 18, 2017 via email

@davidism
Copy link
Copy Markdown
Member Author

Maybe this should be a warning? Could use a filter to turn it into an error in Flask debug mode.

@davidism
Copy link
Copy Markdown
Member Author

davidism commented Apr 18, 2017

How about detecting the before and after version, then warning

The "{key}" cookie is too large: the value was {value_size} bytes but encoding the header required {header_size - value_size} extra bytes. The final size was {header_size} but the limit is {max} bytes. Browsers may silently ignore cookies larger than this.

@untitaker
Copy link
Copy Markdown
Contributor

untitaker commented Apr 18, 2017 via email

@davidism davidism merged commit fbfa21e into pallets:master Apr 18, 2017
@davidism davidism deleted the max-cookie-size branch April 18, 2017 18:25
@Jaza
Copy link
Copy Markdown
Contributor

Jaza commented Apr 19, 2017

Thanks @davidism for making this configurable, there should be need to override the limit of 4k per cookie in most cases, but yes, some people might want to change it.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants