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

actions-for-nautilus doesn't handle specials character in filenames... #53

Open
Creteil opened this issue Dec 24, 2023 · 13 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@Creteil
Copy link

Creteil commented Dec 24, 2023

For example, a file containing an exclamation point :

bigbob@bigbob-t480s:~/Téléchargements$ ll Renouvellement\ de\ Votre\ Domaine\ blacktiger.tech\ Avant\ l\'Expiration\ \!.eml 
3158596 -rw-rw-r-- 1 bigbob bigbob 12612 2023-12-22 15:22:35.350213309 +0100 Renouvellement de Votre Domaine blacktiger.tech Avant l'Expiration !.eml
bigbob@bigbob-t480s:~/Téléchargements$

The log of « Nautilus » say :

bigbob@bigbob-t480s:~/Téléchargements$ # Stop Nautilus
nautilus -q  
# Restart with `stdout` and `stderr` being displayed at the terminal
nautilus --no-desktop
Traceback (most recent call last):
  File "/usr/share/nautilus-python/extensions/actions-for-nautilus/actions_for_nautilus.py", line 56, in _run_command
    final_command_line = list(map(lambda arg: arg.replace("\\\\","!§ESCBACKSLASH§µ").replace("\\", "").replace("!§ESCBACKSLASH§µ","\\"),shlex.split(final_command_line)))
  File "/usr/lib/python3.10/shlex.py", line 315, in split
    return list(lex)
  File "/usr/lib/python3.10/shlex.py", line 300, in __next__
    token = self.get_token()
  File "/usr/lib/python3.10/shlex.py", line 109, in get_token
    raw = self.read_token()
  File "/usr/lib/python3.10/shlex.py", line 191, in read_token
    raise ValueError("No closing quotation")
ValueError: No closing quotation
bigbob@bigbob-t480s:~/Téléchargements$
@bassmanitram
Copy link
Owner

Yes, this is a known -deficiency (dare I say "feature" :D) because these characters are shell characters. It's very difficult to cater for ALL special shell characters. However, I will try to work around this.

@bassmanitram bassmanitram added the bug Something isn't working label Dec 28, 2023
@bassmanitram bassmanitram self-assigned this Dec 28, 2023
@bassmanitram
Copy link
Owner

bassmanitram commented Dec 29, 2023

@Creteil - Sooo - I can actually fairly easily solve this, but it has a tricky downside: It will severely mess with any command that is already using selection quoting or escaping in its own command line string (you know, adding backslashes or single/double quotes ...)

So I'm thinking of one of two ways to address that issue:

  1. Add an option to each command. Something like Disable escaping or something similar (or Enable advanced escaping - you get the idea). This sets the option for the whole command. Easy to implement and understand and probably all that we really need. The user is then responsible for quoting the placeholders. And you can't manually individually quote/escape each instance of a Plural placeholder
  2. Add a second placeholder prefix - say @ that has the same effect as % BUT disables argument escaping. This allows for individual selections to be escaped or not, but is more verbose.

As a user, which would you prefer?

@Creteil
Copy link
Author

Creteil commented Dec 29, 2023

TBH, I leave you the choice, by the way can you show us an example of the 2 options with my filename as input :

  • « Renouvellement de Votre Domaine blacktiger.tech Avant l'Expiration !.eml ».

My actual command :

  • « "command_line": "java -jar /usr/local/bin/emailconverter.jar %d/%b" ».

@bassmanitram
Copy link
Owner

bassmanitram commented Dec 29, 2023

The way I plan it you wouldn't need to do anything because I would get people to change their manually escaped commands to one or the other.

BUT if you were to change your command now to

java -jar /usr/local/bin/emailconverter.jar "%d/%b"

you might find you'll get it to work right now!

Try that

@bassmanitram
Copy link
Owner

(That doesn't mean I'm not gonna fix this - I just think that your case has an immediate workaround)

@Creteil
Copy link
Author

Creteil commented Dec 29, 2023

Yes it work perfect double quoting the original command.... 👍

@bassmanitram
Copy link
Owner

bassmanitram commented Dec 29, 2023

Well NOW you've put yourself in that second group of users who are manually escaping ... so you could leave your quotes in place and either set an option on the command configuration page to disable internal escaping for the command, or change your command to be...

java -jar /usr/local/bin/emailconverter.jar "@d/@b"

(or some other character that I may end up choosing)...

Or, in your simple case, simply remove the quotes when the fix is released, of course. :)

(P.s. - I see you are French - excellent English I must say - I'm a Rosbiff who has lived in France for coming on 30 years - terrible at French still, though :))

@Creteil
Copy link
Author

Creteil commented Dec 29, 2023

You are over-considering my English, on my side, I tend to say :

« I speak English as a Spanish cow... » 🤣🤣🤣

@Creteil
Copy link
Author

Creteil commented Dec 29, 2023

I keep an eye on your next commit for the other way to manage the problem and give it a try...

@acepukas
Copy link

I've just run into this same issue. If there was a way to get the raw string from say %f that would be perfect. Using a different character to indicate "raw", like @, as was suggested would work well because you could then specify it for some parameters while leaving others to shell escape with % in the same command string.

This has come up because I have some files with irksome characters in their file names that the shell doesn't agree with. I could scrub these characters from the files manually of course but it would be nice to be able to leave them as is since the files originate from external sources and it would be kinda tedious to catch them all.

@bassmanitram
Copy link
Owner

bassmanitram commented May 25, 2024 via email

@acepukas
Copy link

Nice! It's a great utility. It let me clean up a lot of nautilus cruft that had been piling up. My old context menu was getting out of hand.

@cheywood
Copy link

Using a different character to indicate "raw" ...

I agree; having access to the raw path would be more useful than/alongside the current partially escaped version. Please :) 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

4 participants