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
Cannot set conditions with a '<' char when others are from type "file" #2231
Merged
Conversation
This file contains 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
When the value of a record received via POST should be tainted (e.g. when the value contains the character '<'), ZPublisher (at least with 4.8.2) does it, but it also does a deepcopy of the records processed earlier. If one (or more) of these records processed earlier is from file type, deepcopy cannot do the job and the following traceback arises: ``` Traceback (innermost last): Module ZPublisher.WSGIPublisher, line 162, in transaction_pubevents Module ZPublisher.WSGIPublisher, line 371, in publish_module Module ZPublisher.WSGIPublisher, line 232, in publish Module ZPublisher.HTTPRequest, line 737, in processInputs Module copy, line 163, in deepcopy\n Module copy, line 230, in _deepcopy_list Module copy, line 190, in deepcopy\n Module copy, line 334, in _reconstruct Module copy, line 163, in deepcopy\n Module copy, line 257, in _deepcopy_dict Module copy, line 190, in deepcopy\n Module copy, line 334, in _reconstruct Module copy, line 163, in deepcopy\n Module copy, line 257, in _deepcopy_dict Module copy, line 182, in deepcopy\nTypeError: can't pickle cStringIO.StringO objects ``` As a result, the base error screen from plone "We’re sorry, but there seems to be an error…" is rendered, but without any error or traceback information Relevant debug info: ``` TypeError: can't pickle cStringIO.StringO objects (Pdb++) where [...] -> self.execute() [6] /home/senaite/dev/buildout-cache/eggs/waitress-1.4.4-py2.7.egg/waitress/task.py(441)execute() -> app_iter = self.channel.server.application(environ, start_response) [7] /home/senaite/dev/buildout-cache/eggs/Paste-3.5.0-py2.7.egg/paste/translogger.py(69)__call__() -> return self.application(environ, replacement_start_response) [8] /home/senaite/dev/buildout-cache/eggs/Zope-4.8.2-py2.7.egg/ZPublisher/httpexceptions.py(30)__call__() -> return self.application(environ, start_response) [9] /home/senaite/dev/buildout-cache/eggs/Zope-4.8.2-py2.7.egg/ZPublisher/WSGIPublisher.py(371)publish_module() -> response = _publish(request, new_mod_info) [10] /home/senaite/dev/buildout-cache/eggs/Zope-4.8.2-py2.7.egg/ZPublisher/WSGIPublisher.py(232)publish() -> request.processInputs() [11] > /home/senaite/dev/buildout-cache/eggs/Zope-4.8.2-py2.7.egg/ZPublisher/HTTPRequest.py(738)processInputs() -> reclist) [12] /home/senaite/dev/Python-2.7/lib/python2.7/copy.py(163)deepcopy() -> y = copier(x, memo) [13] /home/senaite/dev/Python-2.7/lib/python2.7/copy.py(230)_deepcopy_list() -> y.append(deepcopy(a, memo)) [14] /home/senaite/dev/Python-2.7/lib/python2.7/copy.py(190)deepcopy() -> y = _reconstruct(x, rv, 1, memo) [15] /home/senaite/dev/Python-2.7/lib/python2.7/copy.py(334)_reconstruct() -> state = deepcopy(state, memo) [16] /home/senaite/dev/Python-2.7/lib/python2.7/copy.py(163)deepcopy() -> y = copier(x, memo) [17] /home/senaite/dev/Python-2.7/lib/python2.7/copy.py(257)_deepcopy_dict() -> y[deepcopy(key, memo)] = deepcopy(value, memo) [18] /home/senaite/dev/Python-2.7/lib/python2.7/copy.py(190)deepcopy() -> y = _reconstruct(x, rv, 1, memo) [19] /home/senaite/dev/Python-2.7/lib/python2.7/copy.py(334)_reconstruct() -> state = deepcopy(state, memo) [20] /home/senaite/dev/Python-2.7/lib/python2.7/copy.py(163)deepcopy() -> y = copier(x, memo) [21] /home/senaite/dev/Python-2.7/lib/python2.7/copy.py(257)_deepcopy_dict() -> y[deepcopy(key, memo)] = deepcopy(value, memo) [22] /home/senaite/dev/Python-2.7/lib/python2.7/copy.py(182)deepcopy() -> rv = reductor(2) (Pdb++) key 'conditions' (Pdb++) item '<' (Pdb++) reclist[-1] {'attachment': '', 'choices': '', 'description': '', 'required': '', 'title': 'Comentarios TGA', 'type': 'text', 'uid': '3939c785fcce47c9a3425d7e1d28aca2'} (Pdb++) reclist[-2] {'attachment': '', 'choices': '', 'description': 'Si el an\xc3\xa1lisis no se ajusta al esquema anterior, adjuntar fichero con las condiciones de ensayo', 'required': '', 'title': 'Fichero adjunto', 'type': 'file', 'uid': '3939c785fcce47c9a3425d7e1d28aca2', 'value': <ZPublisher.HTTPRequest.FileUpload object at 0x7fd973388b90>} ```
Hmm, maybe it would make sense to file a bug in https://github.com/zopefoundation/Zope/issues? |
|
ramonski
approved these changes
Jan 18, 2023
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.
Description of the issue/feature this PR addresses
This Pull Request overcomes an issue with mixed type records in
ZPublisher
, that prevents to store conditions when a file type control (for a "file" type condition) is present before an input text type control (for a "text" type condition) and user enters a special character (that requires tainting) for the latter. See zopefoundation/Zope#1095 and screenshot belowCurrent behavior before PR
User cannot update analysis conditions if the value set contains the '<' character and the input text is rendered after a file control
Desired behavior after PR is merged
User can update analysis conditions regardless of the contents set for input values
Screenshot
--
I confirm I have tested this PR thoroughly and coded it according to PEP8
and Plone's Python styleguide standards.