-
-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Temporarily disable form memory limit checking for files and images. #1729
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Temporarily disable form memory limit checking for files and images. | ||
This fixes a regression due to a low Zope form memory limit of 1MB used since Plone 6.0.7. | ||
See `CMFPlone issue 3848 <https://github.com/plone/Products.CMFPlone/issues/3848>`_ and `Zope PR 1142 <https://github.com/zopefoundation/Zope/pull/1142>`_. | ||
@maurits |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,20 @@ | ||||||
# TEMPORARY patch for low form memory limit introduced in Zope 5.8.4. | ||||||
# See https://github.com/plone/Products.CMFPlone/issues/3848 | ||||||
# and https://github.com/zopefoundation/Zope/pull/1180 | ||||||
# Should be removed once `plone.restapi.deserializer.json_body` no longer | ||||||
# reads the complete request BODY in memory. | ||||||
from ZPublisher.HTTPRequest import ZopeFieldStorage | ||||||
|
||||||
import logging | ||||||
|
||||||
|
||||||
logger = logging.getLogger(__name__) | ||||||
_attr = "VALUE_LIMIT" | ||||||
_limit = getattr(ZopeFieldStorage, _attr, None) | ||||||
if _limit: | ||||||
setattr(ZopeFieldStorage, _attr, None) | ||||||
logger.info( | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I don't feel strongly about this, but it feels like it's probably noise for most people. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't feel strongly about this either, but I think it would be good to have this noticeable, because it may remind us developers that we still need to fix this instead of having this temporary patch. |
||||||
"PATCH: Disabled ZPublisher.HTTPRequest.ZopeFieldStorage.%s. " | ||||||
"This enables file uploads larger than 1MB.", | ||||||
_attr, | ||||||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on https://github.com/zopefoundation/Zope/blob/master/src/ZPublisher/HTTPRequest.py#L1061, I think we could do (untested):
This will not actually avoid reading the file into memory (https://pythonspeed.com/articles/json-memory-streaming/ makes it clear that json.load still does that) but would bypass the descriptor that enforces the VALUE_LIMIT.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought
BODYFILE
would only be defined when an actual file is being uploaded, and not for example when you POST a login and password. But that is not true.It does not sound like a permanent solution, as this would still offer a way to potentially DOS the server. But maybe very large uploads would still get stopped by one of the other limits. And initial testing seems to work out.
Let me open a different PR, so we still have the current one in case there are problems.