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

docs: non-ASCII hyphens in commands - copy pasting them fails on command line #5903

Open
1 of 4 tasks
danielkrajnik opened this issue Jul 16, 2023 · 11 comments
Open
1 of 4 tasks
Labels
bug Something isn't working documentation Issues and pull requests related to the documentation

Comments

@danielkrajnik
Copy link

danielkrajnik commented Jul 16, 2023

Description

Copying flags from man pages doesn't work - hyphens are encoded as e280 90 instead 2d.

They will look the same, but firejail will error (for example):

Error: invalid --writable‐run‐user command line option

Steps to Reproduce

  1. man firejail
  2. search for an option, e.g. / --writable‐run‐user
  3. select it, copy it, paste it into command line, e.g. firejail --writable‐run‐user
  4. run command
    *5. paste it into a hex editor:

image

Expected Behaviour

enter shell in firejail with /run/user/$UID/gnupg available

Actual Behaviour

Error: invalid --writable‐run‐user command line option

Environment

  • Linux distribution and version: "EndeavourOS" - Arch - package: extra/firejail 0.9.72-1
  • Firejail version:
firejail version 0.9.72

Compile time support:
        - always force nonewprivs support is disabled
        - AppArmor support is enabled
        - AppImage support is enabled
        - chroot support is enabled
        - D-BUS proxy support is enabled
        - file transfer support is enabled
        - firetunnel support is disabled
        - IDS support is disabled
        - networking support is enabled
        - output logging is enabled
        - overlayfs support is disabled
        - private-home support is enabled
        - private-cache and tmpfs as user enabled
        - SELinux support is disabled
        - user namespace support is enabled
        - X11 sandboxing support is enabled

Checklist

  • [] The issues is caused by firejail (i.e. running the program by path (e.g. /usr/bin/vlc) "fixes" it).
  • [] I can reproduce the issue without custom modifications (e.g. globals.local).
  • [] The program has a profile. (If not, request one in https://github.com/netblue30/firejail/issues/1139)
  • The profile (and redirect profile if exists) hasn't already been fixed upstream.
  • I have performed a short search for similar issues (to avoid opening a duplicate).
    • I'm aware of browser-allow-drm yes/browser-disable-u2f no in firejail.config to allow DRM/U2F in browsers.
  • I used --profile=PROFILENAME to set the right profile. (Only relevant for AppImages)
@kmk3 kmk3 added bug Something isn't working documentation Issues and pull requests related to the documentation labels Jul 17, 2023
@vinc17fr
Copy link
Contributor

This is due to the fact that some "-" characters are not escaped with a backslash.

@glitsj16
Copy link
Collaborator

@danielkrajnik When doing the 4 steps to reproduce (in my preferred xfce4-terminal) it actually works fine for me:

$ ls /run/user/$UID/gnupg
S.dirmngr  S.gpg-agent  S.gpg-agent.browser  S.gpg-agent.extra  S.gpg-agent.ssh

Perhaps it's dependent on the terminal-emulator? Have you tried a different one than what you normally use yet?

@rusty-snake
Copy link
Collaborator

@glitsj16 even if it does not happen with all terminals/viewer/... the format is wrong. See @vinc17fr post which writes it down the first time.

with /run/user/$UID/gnupg available

Has nothing todo with writable-run-user.

@danielkrajnik
Copy link
Author

danielkrajnik commented Sep 26, 2023

it actually works fine for me

Strange, it is working for me now as well even though it's the same terminal (alacritty). Maybe switching from Wayland to X11? Or maybe something else changed since July.

@glitsj16
Copy link
Collaborator

Has nothing todo with writable-run-user.

@glitsj16 even if it does not happen with all terminals/viewer/... the format is wrong. See @vinc17fr post which writes it down the first time.

@rusty-snake

The format might be wrong, but how do you explain it sometimes works and sometimes it doesn't? Or in other words, do you have an actionable thing in mind by which we could fix this?

Maybe switching from Wayland to X11?

@danielkrajnik

That's what I'm seeing as well. Not that I can explain the difference...

@rusty-snake
Copy link
Collaborator

#5903 (comment) proper escaping with a backslash.

@glitsj16
Copy link
Collaborator

#5903 (comment) proper escaping with a backslash.

That's already the case:

\fB\-\-writable-run-user

@danielkrajnik
Copy link
Author

danielkrajnik commented Sep 26, 2023

Maybe switching from Wayland to X11?

I've just tried logging out of X11 and logging back into Wayland and it still worked (hyphens were again correctly copied as hex 2d). Both on KDE Plasma. Sorry, not sure what's caused it before.

@kmk3
Copy link
Collaborator

kmk3 commented Sep 26, 2023

I can confirm that this was a problem when the issue was opened, though I can't
immediately reproduce it now either with man-db 2.11.2-1 on Artix.

I also had attempted a regex to fix this, but I didn't finish it.

This is what I had written (the examples are current):


2. search for an option, e.g. / --writable‐run‐user

Error: invalid --writable‐run‐user command line option

GNU man ("man-db" package on Arch Linux) converts - (hyphen-minus) into
e28090 in the output, unless it's escaped as \- in the source and currently
only the first ones are escaped in the man pages, such as in
\-\-writable-run-user (it should be \-\-writable\-run\-user):

$ git grep -E 'writable\\?-run\\?-user' -- src/man/firejail.1.in
src/man/firejail.1.in:\fB\-\-writable-run-user
src/man/firejail.1.in:$ sudo firejail --writable-run-user

Most/all options are unfortunately also half-escaped:

$ git grep ' \\-\\-[^ ]*-' -- src/man/firejail.1.in | head
src/man/firejail.1.in:firejail {\-? | \-\-debug-caps | \-\-debug-errnos | \-\-debug-syscalls | \-\-debug-syscalls32 | \-\-debug-protocols | \-\-help | \-\-version}
src/man/firejail.1.in:$ firejail \-\-dbus-system=none
src/man/firejail.1.in:$ firejail \-\-dbus-user=none
src/man/firejail.1.in:$ firejail \-\-debug-blacklists firefox
src/man/firejail.1.in:$ firejail \-\-debug-caps
src/man/firejail.1.in:$ firejail \-\-debug-errnos
src/man/firejail.1.in:$ firejail \-\-debug-protocols
src/man/firejail.1.in:$ firejail \-\-debug-syscalls
src/man/firejail.1.in:$ firejail \-\-debug-whitelists firefox
src/man/firejail.1.in:$ firejail \-\-disable-mnt firefox

Note that mandoc does not convert them, so this seems to be a GNU-specific
thing.

@vinc17fr
Copy link
Contributor

#5903 (comment) proper escaping with a backslash.

That's already the case:

\fB\-\-writable-run-user

Here I can see

\fB\-\-writable-run-user

The first two are properly escaped, so that they appear correctly in the man page. The other two are not escaped, so that they appear as U+2010 HYPHEN in the man page. This confirms the issue.

@vinc17fr
Copy link
Contributor

GNU man ("man-db" package on Arch Linux) converts - (hyphen-minus) into e28090 in the output, unless it's escaped as \- in the source and currently only the first ones are escaped in the man pages, such as in \-\-writable-run-user (it should be \-\-writable\-run\-user):
[...]
Note that mandoc does not convert them, so this seems to be a GNU-specific thing.

This actually comes from a recent change in groff. See the discussion in Debian bug 1041731.

@kmk3 kmk3 changed the title Hyphens in man pages have incorrect encoding - copy pasting them fails on command line docs: non-ASCII hyphens in commands - copy pasting them fails on command line Aug 23, 2024
kmk3 added a commit to kmk3/firejail that referenced this issue Sep 12, 2024
Remove extranous escape characters and fix bold escaping.

Command used to check for unusual escape sequences:

    $ git grep -E '\\[^ "\f-]|\\f[^BR]' -- src/man/*.in

With this, the only escape sequences used are:

    $ git grep -E -ho -e '\\-' -e '\\[^-][^ ]?' -- src/man/*.in |
      LC_ALL=C sort | uniq -c
          9 \"
          1 \&.
       1194 \-
         23 \\
        507 \fB
        127 \fR

Related commits:

* 1379851 ("Baseline firejail 0.9.28", 2015-08-08)
* 1684c9e ("Fixes for man firejail (netblue30#2628)", 2019-03-29)
* 7352501 ("Clarify that file globbing occurs only at start",
  2020-04-11) / PR netblue30#3347
* f54ee53 ("man text for --include command", 2021-03-05).

This is a follow-up to netblue30#6472.

Kind of relates to netblue30#5903.
kmk3 added a commit to kmk3/firejail that referenced this issue Sep 13, 2024
Remove extranous escape characters and fix bold escaping.

Command used to check for unusual escape sequences:

    $ git grep -E -e '\\f[^BR]' -e '\\[^ "\f-]' -- src/man/*.in

With this, the only escape sequences used are:

    $ git grep -E -ho -e '\\-' -e '\\[^-][^ ]?' -- src/man/*.in |
      LC_ALL=C sort | uniq -c
          9 \"
          1 \&.
       1194 \-
         23 \\
        507 \fB
        127 \fR

Related commits:

* 1379851 ("Baseline firejail 0.9.28", 2015-08-08)
* 1684c9e ("Fixes for man firejail (netblue30#2628)", 2019-03-29)
* 7352501 ("Clarify that file globbing occurs only at start",
  2020-04-11) / PR netblue30#3347
* f54ee53 ("man text for --include command", 2021-03-05).

This is a follow-up to netblue30#6472.

Kind of relates to netblue30#5903.
kmk3 added a commit that referenced this issue Sep 13, 2024
Remove extranous escape characters and fix bold escaping.

Command used to check for unusual escape sequences:

    $ git grep -E -e '\\f[^BR]' -e '\\[^ "\f-]' -- src/man/*.in

With this, the only escape sequences used are:

    $ git grep -E -ho -e '\\-' -e '\\[^-][^ ]?' -- src/man/*.in |
      LC_ALL=C sort | uniq -c
          9 \"
          1 \&.
       1194 \-
         23 \\
        507 \fB
        127 \fR

Related commits:

* 1379851 ("Baseline firejail 0.9.28", 2015-08-08)
* 1684c9e ("Fixes for man firejail (#2628)", 2019-03-29)
* 7352501 ("Clarify that file globbing occurs only at start",
  2020-04-11) / PR #3347
* f54ee53 ("man text for --include command", 2021-03-05).

This is a follow-up to #6472.

Kind of relates to #5903.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Issues and pull requests related to the documentation
Projects
None yet
Development

No branches or pull requests

5 participants