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

Issue #78 Fix handling of plain backslashes #77

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

scroix
Copy link
Member

@scroix scroix commented Jul 19, 2023

I've noticed that escaping behaves a little unexpectedly for example with the following parameters, I get two different results.

image
👇

nodeConfig.json
"AppPath": "C:\\Program Files\\VideoLAN\\VLC\\vlc.exe",
"AppArgs": "C:\\content\\MLK.mp4"

👇
Full command-line: [C:\Program Files\VideoLAN\VLC\vlc.exe C:contentMLK.mp4] (notice the AppArgs have been sanitised)


The behaviour on, for example, PowerShell is that auto completion uses apostrophes to protect strings.

This PR suggests adding the same special case such that I'm able to retain backslashes in my App. Args if I enclose them in apostrophes I retain the string as it is typed into the parameter.

image
👇

nodeConfig.json
"AppArgs": "'C:\\content\\MLK.mp4'"

👇

Full command-line: [C:\Program Files\VideoLAN\VLC\vlc.exe 'C:\content\MLK.mp4']

@justparking
Copy link
Contributor

Hey @scroix, I'm just looking into this issue. I think there might just be a bug in that decodeArgList function with its handling of back-slashes...

One other possible complication to consider is how this is dished off to the sandbox process:
image

I'm not sure if that's affected, but we do need to consider it because it has its own handling of args dictated by .NET (see src_process-sandbox.cs) , as opposed to Nodel with has process args dictated by Java.

@justparking
Copy link
Contributor

justparking commented Jul 24, 2023

Hey @scroix, you've sent me down a little rabbit hole with this one.

I think your proposal of the inverted commas might not necessarily solve all problems. (Ignore the actual bug related to escaping, issue #78.)

I remember identifying this as an issue when I wrote the Sandbox process:

When the sandbox runs and passes on the list of arguments, C#/.NET automatically strips any quotes away.

This process tree shows exactly what's happening:

image

nodel launches sanbox process and correctly encloses arg in quotes:

...\Temp\nodel-proc-sandbox-2.2.1-dev_r468.exe --ppid 17188 "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" "c:\content\Sample Video File For Testing.mp4"

sandbox process launches vlc but it ends up not being in quotes:

...\vlc.exe" c:\content\Sample Video File For Testing.mp4

This trips up VLC because it treats it like 4 items in a playlist, i.e. c:\content\Sample, Video, File, For, and Testing.mp4.

Unfortunately this is because of the way .NET handles arguments in normal programs using as seems to strip quotes as a convenience to the programmer:

    static void Main(string[] args)
    {

I believe a proper fix to this problem would be for the SandBox process to make use of the Environment.CommandLine instead of the class static void Main method, see api/system.environment.commandline.

That's definitely doable but the argument parser code needs to be restructured - see line 129 in src_process-sandbox.cs.

I'm happy to look into this but can't do it for at least a week.

@scroix
Copy link
Member Author

scroix commented Jul 26, 2023

Thank you for all your efforts investigating.

I'm happy to look into this but can't do it for at least a week.

It's very minor, no rush, add it to the backlog. 📃

I've come up with a work around which I'd recommend to others. I realised in the case of VLC I could actually just change the working directory to avoid the use of backslashes (in the app. args) all-together.

image

e.g. Full command-line: [C:\Program Files\VideoLAN\VLC\vlc.exe rania_interstitial_16bpc_test.mov]

@scroix scroix marked this pull request as draft May 18, 2024 05:06
@scroix scroix closed this May 21, 2024
@scroix scroix deleted the app_launcher/more-escape-handlers branch May 21, 2024 05:19
scroix and others added 3 commits May 21, 2024 15:22
- Adds backslash to current arg when escaping
- Simplifies space and quote handling
- Clears current arg after appending to list
@scroix scroix reopened this May 21, 2024
@scroix
Copy link
Member Author

scroix commented May 21, 2024

I've returned to this issue after your explanation (@justparking) cleared things up for me. This PR now focuses just on addressing the issue with decodArgList not handling back slashes.

This is also described in #78

@scroix scroix changed the title Introduce special case for apostrophe in App. Args Fix handling of plain backslashes #78 May 21, 2024
@scroix scroix changed the title Fix handling of plain backslashes #78 #78 Fix handling of plain backslashes May 21, 2024
@scroix scroix changed the title #78 Fix handling of plain backslashes Issue #78 Fix handling of plain backslashes when using sandbox May 21, 2024
@scroix scroix changed the title Issue #78 Fix handling of plain backslashes when using sandbox Issue #78 Fix handling of plain backslashes May 21, 2024
@scroix scroix marked this pull request as ready for review May 21, 2024 05:45
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