Skip to content

fix lib/dtutils/system/open_default_app() #172

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

Merged
merged 1 commit into from
Feb 26, 2019

Conversation

wpferguson
Copy link
Member

Added a space after the commands and removed quotes around the path argument in the command invocation.

@wpferguson wpferguson merged commit 2b2a09e into darktable-org:master Feb 26, 2019
@wpferguson wpferguson deleted the fix_open_default_app branch February 26, 2019 17:16
end
return dtutils_system.external_command(open_cmd..' "'..path..'"')
return dtutils_system.external_command(open_cmd .. path)
Copy link
Contributor

Choose a reason for hiding this comment

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

@wpferguson path is not sanitized, this breaks Linux version when there is space in the path

Copy link
Member Author

Choose a reason for hiding this comment

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

The caller should send a sanitized path to the function, rather than the function assuming the path isn't sanitized. Also windows and linux/macos have different quoting requirements. lib/dtutils/file/sanitize_filename() is provided for that purpose. The author of the script calling the function should know whether the path being passed needs to be sanitized or not and pass the argument appropriately. Or, they can be safe and sanitize it anyway.

Think of the libraries as little black boxes. There is documentation about what the input should be and what output is expected. So, I decide to use this function. I pass it a path and sanitize it because it includes a space. Unknown to me, unless I went in an looked at the code, the function attempts to sanitize my sanitized string. The quotes cancel out and the command crashes because the string wasn't sanitized. I would be very confused if this happened, because I knew that I had passed a sanitized string and my script crashed because the string wasn't sanitized. And the solution wouldn't really make sense because I would have to not sanitize my string in order for it to be sanitized.

Copy link
Contributor

Choose a reason for hiding this comment

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

For me both options (expect sanitized path or not) would work if it's covered in documentation, but I personally prefer to have this in the lib itself. It was my fault that it wasn't documented properly. Anyway, seems like #173 fix problem in video_ffmpg.

I think, we should then remove sanitize from lib/dtutils/file/rm and lib/dtutils/file/mkdir to be consistent or change sanitize method to be idempotent (preferred).

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