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

Audacity fails to parse “~” tilde for user’s home directory in export audio dialog #6417

Open
InconsolableCellist opened this issue May 10, 2024 · 4 comments
Labels
bug An error, undesired behaviour, or missed functionality

Comments

@InconsolableCellist
Copy link

InconsolableCellist commented May 10, 2024

Bug description

Problem Description:
When exporting audio, Audacity fails to interpret the “~” tilde on Linux, which should expand to the user’s home ($HOME) directory.

Steps to reproduce

Steps to reproduce:

  1. Open Audacity
  2. Create some audio (e.g., generate 440 Hz sine wave for 1 second)
  3. Select All
  4. Click File-> Export Audio
  5. In the “Folder” field in the dialog box that pops up, enter “~/somedir”
  6. (optional?) set “WAV (Microsoft)”, Mono, 44100 Hz, Signed 16-bit PCM, Entire Project
  7. Click Export

Expected behavior

Expected Behavior
The file should be saved in $HOME/somedir/untitled.wav. The “~” needs to expand to the home directory.

Actual behavior

Observed Behavior
The file will be saved in $HOME/~/somedir/untitled.wav. Note the inclusion of the string literal “~” in the path. $HOME refers to the environment variable where the user’s home directory is, usually something like /home/user/

Audacity Version

latest stable version (from audacityteam.org/download)

Operating system

Linux

Additional context

Environment
Artix Linux
Audacity 3.5.1
KDE Plasma 6

Other
This also invites disaster for an unsuspecting user, who might attempt to rm -rf the errant “~” directory and could end up with a very bad day

@InconsolableCellist InconsolableCellist added the bug An error, undesired behaviour, or missed functionality label May 10, 2024
@rbdannenberg
Copy link
Collaborator

I'm pretty sure ~ is interpreted by the shell, and file IO primitives including system commands like open do not do regular expression matching or convert ~ to $HOME or replace $HOME for that matter. So you could actually name a file "~" or "$HOME" although it's obviously a bad idea.

@InconsolableCellist
Copy link
Author

InconsolableCellist commented May 10, 2024

All GTK+ file pickers/choosers, Qt, KDE, and all popular desktop applications support "~" expansion.

E.g., right click this page in Firefox or Chrome, type ~/somefile.txt and it'll save it in $HOME/somefile.txt.

Shells do also expand ~ but it isn't limited to a shell feature

@InconsolableCellist
Copy link
Author

According to a comment in the forum (https://forum.audacityteam.org/t/bug-audacity-fails-to-parse-tilde-for-users-home-directory-in-export-audio-dialog/106141) this may be a regression after 3.4.2

@dozzzzer dozzzzer changed the title [Bug] Audacity fails to parse “~” tilde for user’s home directory in export audio dialog Audacity fails to parse “~” tilde for user’s home directory in export audio dialog May 10, 2024
@LWinterberg
Copy link
Member

It's not technically a regression - before 3.4, the export dialog was a customized file picker. Now, the "browse" button in the export dialog opens the native (and unmodified) file picker, while the box inside the export dialog just is a textbox.

A fix for this probably involves validating mFullName in ExportFilePanel.cpp. There already is ExportFilePanel::ValidateAndFixExt() which does the same for invalid characters in the filename.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error, undesired behaviour, or missed functionality
Projects
None yet
Development

No branches or pull requests

3 participants