Skip to content

ls: encode path when using --hyperlink#5629

Merged
sylvestre merged 1 commit intouutils:mainfrom
cakebaker:ls_hyperlink_encode
Dec 18, 2023
Merged

ls: encode path when using --hyperlink#5629
sylvestre merged 1 commit intouutils:mainfrom
cakebaker:ls_hyperlink_encode

Conversation

@cakebaker
Copy link
Copy Markdown
Contributor

This PR encodes special characters in a path when using --hyperlink.

@cakebaker cakebaker force-pushed the ls_hyperlink_encode branch 2 times, most recently from 17b77fc to 87db427 Compare December 9, 2023 16:24
@cakebaker cakebaker marked this pull request as draft December 9, 2023 16:52
@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 9, 2023

GNU testsuite comparison:

Congrats! The gnu test tests/ls/multihardlink is no longer failing!
Congrats! The gnu test tests/ls/root-rel-symlink-color is no longer failing!

@cakebaker cakebaker force-pushed the ls_hyperlink_encode branch 3 times, most recently from a589406 to 33b84fc Compare December 10, 2023 12:29
@cakebaker cakebaker marked this pull request as ready for review December 10, 2023 12:49
@cakebaker cakebaker force-pushed the ls_hyperlink_encode branch 2 times, most recently from 3650355 to c1a0c45 Compare December 10, 2023 15:15
@sylvestre
Copy link
Copy Markdown
Contributor

is it expected that it does not fix the GNU test?

@cakebaker
Copy link
Copy Markdown
Contributor Author

@sylvestre yes, unfortunately :|

Copy link
Copy Markdown
Collaborator

@tertsdiepraam tertsdiepraam left a comment

Choose a reason for hiding this comment

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

Awesome! That's looking great! One final question but ready to be merged I think.

Comment on lines +3022 to +3025
#[cfg(not(target_os = "windows"))]
let unencoded_chars = "_-.:~/";
#[cfg(target_os = "windows")]
let unencoded_chars = "_-.:~\\";
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I should've asked this on the previous review, but did you check GNU for the backslash? I think maybe Windows either needs both back and forward slash (because both are allowed) or only forward slash because that matches the spec (as explained on the wikipedia page: https://en.wikipedia.org/wiki/Percent-encoding). Although of course maybe the way GNU does it is different from the spec that wikipedia describes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

GNU encodes backslashes. And as Windows uses backslashes in paths I thought it doesn't make sense to encode them on Windows. It's guess work from my side, as I don't know Windows. In the latest push I added the forward slash to unencoded_chars.

@uutils uutils deleted a comment from github-actions bot Dec 16, 2023
@sylvestre sylvestre merged commit 0fa074f into uutils:main Dec 18, 2023
@cakebaker cakebaker deleted the ls_hyperlink_encode branch December 18, 2023 12:46
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.

3 participants