Skip to content

Conversation

@srikaaviya
Copy link
Contributor

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:

  1. Checks if the uploaded file is binary based on .
  2. Skips text decoding for binary files.
  3. Updates the item's contenttype metadata to match the uploaded file, ensuring subsequent validation passes.

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.\n\nThis commit:\n1. Checks if the uploaded file is binary based on .\n2. Skips text decoding for binary files.\n3. Updates the item's contenttype metadata to match the uploaded file, ensuring subsequent validation passes.
@UlrichB22
Copy link
Collaborator

@srikaaviya, did you install the pre-commit hooks in your development environment as described in
https://moin-20.readthedocs.io/en/latest/devel/development.html#install-pre-commit-hooks ?

@roland-ruedenauer
Copy link
Contributor

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?

@UlrichB22
Copy link
Collaborator

Does Moin2 even support switching markup type from e.g. markdown to rST?

Yes, there is a Convert action in the items view.

@UlrichB22 UlrichB22 marked this pull request as draft January 26, 2026 16:43
@srikaaviya
Copy link
Contributor Author

@srikaaviya, did you install the pre-commit hooks in your development environment as described in https://moin-20.readthedocs.io/en/latest/devel/development.html#install-pre-commit-hooks ?

Yes, I installed and ran the pre-commit hooks.

@srikaaviya
Copy link
Contributor Author

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, 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?

@UlrichB22
Copy link
Collaborator

Yes, please add the check to avoid tracebacks.
It would be nice if you can squash the first commits.

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.

3 participants