Skip to content

Comments

Encode .trashinfo Path with encodeURI as per XDG spec#134

Merged
sindresorhus merged 1 commit intosindresorhus:mainfrom
sanand0:encode-special-characters
Dec 7, 2025
Merged

Encode .trashinfo Path with encodeURI as per XDG spec#134
sindresorhus merged 1 commit intosindresorhus:mainfrom
sanand0:encode-special-characters

Conversation

@sanand0
Copy link
Contributor

@sanand0 sanand0 commented Nov 26, 2025

The XDG trash spec requires the .trashinfo Path= entry to be percent-encoded (RFC 2396).

The current implementation encodes only spaces, not other characters. This impacts files with special / non-ASCII characters in their names.

This change:

  • Use encodeURI(filePath) to encoded paths properly (not just spaces).
  • Updates the create trashinfo test to validate 'f2 ^' instead of 'f2', introducing a special character in addition to space.
  • Update README XDG spec link to the current official trash spec URL.

The [XDG trash spec](https://specifications.freedesktop.org/trash/1.0/)
requires the .trashinfo Path= entry to be percent-encoded (RFC 2396).

The current implementation encodes only spaces, not other characters.
This impacts files with special / non-ASCII characters in their names.

This change:

- Use encodeURI(filePath) to encoded paths properly (not just spaces).
- Updates the `create trashinfo` test to validate `'f2 ^'` instead of `'f2'`,
  introducing a special character in addition to space.
- Update README XDG spec link to the current official trash spec URL.
@sindresorhus sindresorhus merged commit b848409 into sindresorhus:main Dec 7, 2025
6 checks passed
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