Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix i3-dmenu-desktop quoting #5162

Merged
merged 1 commit into from
Sep 28, 2022
Merged

Fix i3-dmenu-desktop quoting #5162

merged 1 commit into from
Sep 28, 2022

Conversation

stapelberg
Copy link
Member

Commit 70f23ca introduced new issues.

Instead of distinguishing " and , as that commit attempted, let’s instead keep the level of escaping by escaping each backslash, just like each double quote.

I tested this with:

# recommended way to quote $ and " in quoted arguments, not ambiguous
Exec=/tmp/logargs "hello \\$PWD \\"and\\" more"

# permitted way to quote $ and " in quoted arguments, but ambiguous
Exec=/tmp/logargs "hello \$PWD \"and\" more"

# permitted way to quote arguments, slightly unusual to quote first arg
Exec="/tmp/logargs" hey

# a complicated shell expression, not ambiguous
Exec=sh -c "if [ -n \\"\\$*\\" ]; then exec /tmp/logargs --alternate-editor= --display=\\"\\$DISPLAY\\" \\"\\$@\\"; else exec /tmp/logargs --alternate-editor= --create-frame; fi" placeholder %F

related to #4697 (electrum, original)

related to #5152 (phpstorm, breakage)

related to #5156 (emacsclient, breakage)

@stapelberg
Copy link
Member Author

Depending on the timing of the bugfix release, I can try to add tests for i3-dmenu-desktop, so let’s not merge this right away.

I just wanted to send the PR so that affected folks can try it out :)

Copy link
Member

@orestisfl orestisfl left a comment

Choose a reason for hiding this comment

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

Tests would be nice 👍

Commit 70f23ca introduced new issues.

Instead of distinguishing " and \, as that commit attempted,
let’s instead keep the level of escaping by escaping each backslash,
just like each double quote.

I tested this with:

    # recommended way to quote $ and " in quoted arguments, not ambiguous
    Exec=/tmp/logargs "hello \\$PWD \\"and\\" more"

    # permitted way to quote $ and " in quoted arguments, but ambiguous
    Exec=/tmp/logargs "hello \$PWD \"and\" more"

    # permitted way to quote arguments, slightly unusual to quote first arg
    Exec="/tmp/logargs" hey

    # a complicated shell expression, not ambiguous
    Exec=sh -c "if [ -n \\"\\$*\\" ]; then exec /tmp/logargs --alternate-editor= --display=\\"\\$DISPLAY\\" \\"\\$@\\"; else exec /tmp/logargs --alternate-editor= --create-frame; fi" placeholder %F

related to i3#4697 (electrum, original)
related to i3#5152 (phpstorm, breakage)
related to i3#5156 (emacsclient, breakage)
@stapelberg
Copy link
Member Author

Tests added and merged :)

stapelberg added a commit that referenced this pull request Oct 24, 2022
Commit 70f23ca introduced new issues.

Instead of distinguishing " and \, as that commit attempted,
let’s instead keep the level of escaping by escaping each backslash,
just like each double quote.

I tested this with:

    # recommended way to quote $ and " in quoted arguments, not ambiguous
    Exec=/tmp/logargs "hello \\$PWD \\"and\\" more"

    # permitted way to quote $ and " in quoted arguments, but ambiguous
    Exec=/tmp/logargs "hello \$PWD \"and\" more"

    # permitted way to quote arguments, slightly unusual to quote first arg
    Exec="/tmp/logargs" hey

    # a complicated shell expression, not ambiguous
    Exec=sh -c "if [ -n \\"\\$*\\" ]; then exec /tmp/logargs --alternate-editor= --display=\\"\\$DISPLAY\\" \\"\\$@\\"; else exec /tmp/logargs --alternate-editor= --create-frame; fi" placeholder %F

related to #4697 (electrum, original)
related to #5152 (phpstorm, breakage)
related to #5156 (emacsclient, breakage)
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