-
-
Notifications
You must be signed in to change notification settings - Fork 5k
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 for #906, 1) windows paths like C:\a\b weren't accepted because b… #935
Conversation
moltenform
commented
Oct 31, 2018
- windows paths like C:\a\b weren't accepted because backslashes were treated as escape sequences,
- common paths like C:\Program Files\Foo\Foo.exe weren't accepted because of the space in the path
…because backslashes were treated as escape sequences, 2) common paths like C:\Program Files\Foo\Foo.exe weren't accepted because of the space in the path
Thanks for the patch. Do you know what part of the code was treating "" as an escape character? Maybe, rather than escaping the path, whatever was incorrectly treating \ as escape character should be fixed? |
It's splitCommandString() that is both treating \ as an escape character and treating spaces as separating arguments. This is right for Linux, where paths don't usually have spaces, but isn't expected in Windows. True, a simpler approach could be to simply skip splitCommandString() on Windows and pass the string as one argument. I doubt that Windows users would need to pass flags to a .exe. This would be a simpler ~5 line patch, along with a new string, since the documentation string says "The editor command (may include arguments) that will be used..." would have a Windows version that says "The editor command that will be used..." If that would be preferred, I'll update the pr. |
Hmm, yes I think the bug is indeed in splitCommandString(). I've converted this function from some of my Golang code but it was used in a different context where escaping needed to be supported. However in this case we don't ever need escaping - the app should just take whatever string the user provided and run this. So yes I think if you could fix this function by making its ability to escape option it should be fine. Like the signature would be this:
For the spaces in Windows, the splitCommandString function supports quotes around paths so we don't need to do something special for this. Perhaps we could add a description below the field though - something like "If you path contains spaces, add double quotes around it". |
When I update joplin.pot, which script should I run to regenerate locales/*.js ? (I'm guessing something related to gettext) |
You don't need to regenerate the .pot file, I take care of it when I rebuild all the translations. If you want a string to be translated, simply wrap it in |
a) backslashes are no longer treated as escape characters, b) string change to remind people to add spaces
} | ||
|
||
// in windows, \ usually is a path delim, not an escape sequence | ||
cmd = cmd.replace(/\\/g, '\\\\'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason we still need this, since in splitCommandString you are now disabling escape?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, good catch.
Sorry I missed your new commits from a few days ago. I think it's almost ready to merge but I just have one question on one of the changes. If you could just confirm on this that would be great. |
Sounds good. |
Thanks @downpoured! |
Thanks! By the way, I'm thinking of changing my username on here to 'moltenjs' within the next few days, GitHub seems to handle this fine, but letting you know just in case. |