Skip to content

fix: sanitize names on file operations - #2546

Merged
joelim-work merged 8 commits into
gokcehan:masterfrom
valoq:prompt
May 19, 2026
Merged

fix: sanitize names on file operations#2546
joelim-work merged 8 commits into
gokcehan:masterfrom
valoq:prompt

Conversation

@valoq

@valoq valoq commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

Addresses missing sanitation on filenames prompts like rename

@valoq

valoq commented Apr 28, 2026

Copy link
Copy Markdown
Contributor Author

Fixed a bug where the status message color was stripped as well.

Note that this will mostly be simplified by a followup refactor once it is merged along with the related PRs

@valoq

valoq commented May 8, 2026

Copy link
Copy Markdown
Contributor Author

Added sanitation for history entries.

With this PR merged, lf will handle all filenames with the same sanitation that is applied by ls from coreutils.

@valoq

valoq commented May 16, 2026

Copy link
Copy Markdown
Contributor Author

@joelim-work Can we try to get this one merged for r42?
It would allow me to refactor the existing filter code for better readability which then concludes this entire sanitation topic.

@joelim-work joelim-work left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes here look fine, but at this point I'd like to know what your plans for sanitization are. With this change there will now be three types of sanitization:

  • sanitizeName: The most strict version, does not allow control characters
  • sanitizeForDisplay: Allows tabs
  • sanitizeMessage: Allows terminal sequences

I did a quick search of the codebase to see which type of sanitization is used for which feature:

Feature Sanitization Type
Default preview sanitizeForDisplay
Sixel preview sanitizeForDisplay
Directory view pane sanitizeName
Prompt line sanitizeName
Ruler sanitizeName
Command line sanitizeName
Menus sanitizeName
Query output sanitizeName
Echo sanitizeNessamge
Echoerr (expects plain string formatted by errorfmt) sanitizeName

For a given feature, how do you decide which type of sanitization is required? Regarding future development, I can easily see the possibility where contributors either use the wrong type of sanitization or forget about sanitization altogether.

Comment thread ui.go
Comment thread ui.go Outdated
@valoq

valoq commented May 18, 2026

Copy link
Copy Markdown
Contributor Author

For a given feature, how do you decide which type of sanitation is required? Regarding future development, I can easily see the possibility where contributors either use the wrong type of sanitation or forget about sanitation altogether.

Thats exactly why I plan to refactor all sanitation code and have it in a separate source file along with simple instructions that describe which one is which. At the moment these functions are spread all over.

@joelim-work joelim-work left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I think the changes look fine now, thanks once again for the patch.

@joelim-work
joelim-work merged commit 0ca4d75 into gokcehan:master May 19, 2026
32 checks passed
joelim-work added a commit that referenced this pull request May 19, 2026
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.

2 participants