dyne / tomb

the Crypto Undertaker
https://dyne.org/software/tomb
GNU General Public License v3.0
1.32k stars 151 forks source link

Fix spaces in bind-hooks paths #500

Closed Llewellynvdm closed 7 months ago

Llewellynvdm commented 8 months ago

https://github.com/dyne/Tomb/blob/a0b633fb774626e6f6e9767b70247bf5490dd0e2/tomb#L2593-L2604

The option to target folders/files that have spaces in the name would be ideal, so I added a little work around.

Llewellynvdm commented 8 months ago

This should also resolve https://github.com/dyne/Tomb/issues/433

Llewellynvdm commented 7 months ago

@jaromil is there a particular reason why this PR is in limbo?

jaromil commented 7 months ago

Hi! Many thanks for your PR! It not in limbo, just some delay due to new year's holiday and the fact this project is ran by volunteers.

I am just wondering if the renaming to __ESC_SPACE__ is appropriate, or shall we just use a _ underscore for the generated targets used by bind mount.

Llewellynvdm commented 7 months ago

The use of __ESC_SPACE__ as a placeholder in the script serves a specific purpose: it is intended to be a unique sequence that is unlikely to occur in actual file or directory names. This uniqueness is essential because the placeholder temporarily represents spaces in paths during processing to avoid issues with word splitting.

If we were to use a single underscore _, there is a real possibility that actual path names could contain underscores. These would then be erroneously converted to spaces when the placeholder is reverted, leading to incorrect path names. By using __ESC_SPACE__, we mitigate this risk because it is designed to stand out and not conflict with typical naming conventions.

Therefore, while the placeholder may seem verbose or unconventional, its distinctive pattern is a safeguard to ensure that only the intended spaces are replaced and then accurately restored, preserving the integrity of the file paths during the bind mount process.

jaromil commented 7 months ago

Excellent explanation, thanks for all your attention to details and welcome among the Tomb contributors!