censor/Censor
1
37
Fork
You've already forked Censor
3

feat: sanitize document when saving #117

Closed
mahlzahn wants to merge 1 commit from mahlzahn/feat_sanitization into main AGit
pull from: mahlzahn/feat_sanitization
merge into: censor:main
censor:main

Related: #3

Related: #3
feat: sanitize document when saving
All checks were successful
/ build-start (pull_request_target) Successful in 9s
/ checks (pull_request) Successful in 1m3s
/ merge-conditions (pull_request) Successful in 7s
/ release-publish (pull_request_target) Has been skipped
560178da4f
Related: #3 

Note

The build job for 560178da4f finished with status success. Install and run the x86_64 test build with:

curl https://gitlab.gnome.org/mahlzahn/censor-ci/-/jobs/6247229/artifacts/raw/censor-dev.flatpak -o censor-dev.flatpak
flatpak install --user censor-dev.flatpak
flatpak run --user page.codeberg.censor.Censor.Devel
> **Note** > The [build job](https://gitlab.gnome.org/mahlzahn/censor-ci/-/jobs/6247229) for 560178da4fc2779e4a3ec71947436fa47d5aa4a5 finished with status **success**. Install and run the x86_64 test build with: > > curl https://gitlab.gnome.org/mahlzahn/censor-ci/-/jobs/6247229/artifacts/raw/censor-dev.flatpak -o censor-dev.flatpak > flatpak install --user censor-dev.flatpak > flatpak run --user page.codeberg.censor.Censor.Devel
mahlzahn added this to the v0.5.0 milestone 2026年03月06日 18:11:22 +01:00
@ -135,0 +150,4 @@
thumbnails=True,
xml_metadata=True)
except Exception as e:
print("WARNING: Sanitization of the document did not succeed")
Author
Owner
Copy link

add toast or warning dialog to UI

add toast or warning dialog to UI
Author
Owner
Copy link

Done in !140.

Done in !140.
mahlzahn marked this conversation as resolved
@ -135,0 +144,4 @@
redactions=False,
redact_images=0,
# Do not remove links
remove_links=False,
Author
Owner
Copy link

Unsure about this option: the links may contain sensitive information, but maybe they should not be removed?

Unsure about this option: the links may contain sensitive information, but maybe they should not be removed?
Author
Owner
Copy link

They are now kept by default in !140. Might add setting later.

They are now kept by default in !140. Might add setting later.
mahlzahn marked this conversation as resolved
@ -135,0 +146,4 @@
# Do not remove links
remove_links=False,
reset_fields=True,
reset_responses=True,
Author
Owner
Copy link

I am also unsure about these options. I can imagine that I filled a form and want to still redact some parts.

I am also unsure about these options. I can imagine that I filled a form and want to still redact some parts.
Author
Owner
Copy link

They are now removed by default in !140. Might add a setting later. Check influence.

They are now removed by default in !140. Might add a setting later. Check influence.
mahlzahn marked this conversation as resolved
@ -135,0 +139,4 @@
embedded_files=True,
hidden_text=True,
javascript=True,
metadata=True,
Author
Owner
Copy link

Check what exactly is redacted, it should be probably optional.

Check what exactly is redacted, it should be probably optional.
Author
Owner
Copy link

See #3 (comment). May make optional later. Now, with !140, metadata is removed by default.

See https://codeberg.org/censor/Censor/issues/3#issuecomment-11360956. May make optional later. Now, with !140, metadata is removed by default.
mahlzahn marked this conversation as resolved
@ -135,0 +137,4 @@
attached_files=True,
clean_pages=True,
embedded_files=True,
hidden_text=True,
Author
Owner
Copy link

Depends, check what it does.

Depends, check what it does.
Author
Owner
Copy link

May make optional later. Now, with !140, hidden text is removed by default.

May make optional later. Now, with !140, hidden text is removed by default.
mahlzahn marked this conversation as resolved
@ -132,6 +132,26 @@ class Document:
images=pymupdf.PDF_REDACT_IMAGE_PIXELS,
graphics=pymupdf.PDF_REDACT_LINE_ART_REMOVE_IF_TOUCHED,
text=pymupdf.PDF_REDACT_TEXT_REMOVE)
try:
Author
Owner
Copy link

Split scrubbing for all options, thus, if it is failing for one, it still executes the rest.

Split scrubbing for all options, thus, if it is failing for one, it still executes the rest.
Author
Owner
Copy link

Done in !140

Done in !140
mahlzahn marked this conversation as resolved
mahlzahn left a comment
Copy link
-tmp.write(mupdf_document.tobytes(garbage=3))
+tmp.write(mupdf_document.tobytes(garbage=1, clean=True, deflate=True, deflate_images=True, deflate_fonts=True))

Decrease document size, sanitize better?

Edit: included in !140.

```diff -tmp.write(mupdf_document.tobytes(garbage=3)) +tmp.write(mupdf_document.tobytes(garbage=1, clean=True, deflate=True, deflate_images=True, deflate_fonts=True)) ``` Decrease document size, sanitize better? Edit: included in !140.
mahlzahn removed this from the v0.5.0 milestone 2026年03月14日 11:39:18 +01:00
Author
Owner
Copy link

!140 includes the sanitization, thus, closing this PR here.

!140 includes the sanitization, thus, closing this PR here.
mahlzahn closed this pull request 2026年03月14日 13:35:36 +01:00
All checks were successful
/ build-start (pull_request_target) Successful in 9s
Required
Details
/ checks (pull_request) Successful in 1m3s
Required
Details
/ merge-conditions (pull_request) Successful in 7s
Required
Details
/ release-publish (pull_request_target) Has been skipped

Pull request closed

Please reopen this pull request to perform a merge.
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
censor/Censor!117
Reference in a new issue
censor/Censor
No description provided.
Delete branch "mahlzahn/feat_sanitization"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?