Sanitize filenames to remove URI-illegal characters#54
Merged
Mayuresh Pawar (Mayureshpawar29) merged 5 commits intomainfrom Apr 3, 2026
Merged
Sanitize filenames to remove URI-illegal characters#54Mayuresh Pawar (Mayureshpawar29) merged 5 commits intomainfrom
Mayuresh Pawar (Mayureshpawar29) merged 5 commits intomainfrom
Conversation
Add sanitizeFilename() to the EML converter that replaces characters not in [a-zA-Z0-9_-.] with hyphens, collapses consecutive hyphens, and trims leading/trailing hyphens. Applied to all converter outputs (attachments, inlines, body parts, headers).
Replaced the existing converter.SanitizeFileName function with textutil.SlugifyFileName across multiple files, including tar, zip, file, and various converter implementations. This change centralizes filename sanitization logic and improves consistency in handling filenames. Additionally, a new textutil package was introduced to encapsulate the slugification logic.
Divyanshu Tiwari (divyanshu-tiwari)
approved these changes
Apr 3, 2026
Mahesh Kamble (ma-gk)
approved these changes
Apr 3, 2026
This file contains hidden or 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
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
textutil.SlugifyFileNamefunction that replaces URI-unsafe characters in filenames (spaces, parentheses, brackets, unicode, etc.) with hyphens, collapses consecutive hyphens, andfalls back to
attachmentfor fully non-alphanumeric namesconverter.SanitizeFileNamewithtextutil.SlugifyFileNameacross all tasks (EML, CSV, XLSX, tar, zip, file) for consistent filename handlingTest Cases —
SlugifyFileNamereport.csvreport.csvreport-000000000000 (1).csvreport_000000000000_1.csvMy Report [Final].CSVmy_report_final.csvrésumé données.pdfr_sum_donn_es.pdf...attachmentfile with spaces.txtfile_with_spaces.txt(attachment).csvattachment.csvSlugifyReport (1)report_1My Report [Final]my_report_finalhello worldhello_worldrésumé donnéesr_sum_donn_es___already_trimmed___already_trimmedUPPER CASEupper_case...Types of changes
Checklist