-
-
Notifications
You must be signed in to change notification settings - Fork 102
Fix: Handle binary file uploads on Plain Text pages correctly #2125
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
base: master
Are you sure you want to change the base?
Conversation
|
@srikaaviya, did you install the pre-commit hooks in your development environment as described in |
|
I'm not quite sure if it is a good idea to be able to switch from "text" content to binary content. One immediate problem this will trigger is how diffs between item revisions behave. Does Moin2 even support switching markup type from e.g. markdown to rST? |
Yes, there is a |
Yes, I installed and ran the pre-commit hooks. |
Yes, switching content types will cause the Diff view to crash. However, I can implement a safety check to fix this: if the content types are different, the Diff view will simply show a message saying they cannot be compared, instead of error. Will it work? |
|
Yes, please add the check to avoid tracebacks. |
31e29a4 to
175e5c3
Compare
| return _crash(item, oldrev, newrev) | ||
| try: | ||
| diff_html = Markup(item.content._render_data_diff(oldrev, newrev, rev_links=rev_links, fqname=fqname)) | ||
| except Exception: |
Check warning
Code scanning / Bandit
Potential XSS with markupsafe.Markup detected. Do not use Markup on untrusted data. Warning
Done! I've added the checks to prevent the traceback and squashed the commits. |
|
Thanks for the updates.
|
cb9b1c6 to
333115a
Compare
|
Thanks for review. I reverted the pyproject.toml changes. Also displayed the error message as warning |
Previously, uploading a binary file (e.g., .pages, .pdf) to replace a Text page caused a 'UnicodeDecodeError or data validation error' because the system attempted to decode the binary content as text based on the existing page type.
This commit: