[Tuxpaint-devel] Tux Paint & Tux Paint Config. and quotes in config file settings
An award-winning drawing program for children of all ages
Brought to you by:
wkendrick
From: Bill K. <nb...@so...> - 2023-06-07 05:57:53
|
On Linux/Unix, Tux Paint uses "wordexp()" to do some word expansion of config-file arguments, e.g. you can specify savedir=$HOME/tuxpaint/ and it will do what you'd expect. However, if there are spaces, things go bonkers. I didn't notice this myself, because I avoid spaces in file and directory names, and also don't really fiddle with my Tux Paint settings much! I DID notice it once I added the new "uifont" option, because many font family names contain spaces (e.g., "Ubuntu Condensed", "Open Sans Condensed", "Nimbus Sans Narrow", "Bitstream Vera Sans Mono", etc.) So I made sure Tux Paint Config. wrapped the font name in quotes, which worked for me on Linux because Tux Paint is using wordexp(), but Shin-ichi quickly pointed out that Windows does NOT use wordexp(), so Tux Paint would try to load non-existent fonts, due to the extraneous quotes! In experimenting, I then discovered wordexp() was being used unsafely, and Tux Paint could CRASH (segfault!) when trying to read a config-file setting like: savedir=$HOME/dir with space/ It works fine with quotes: savedir="$HOME/dir with space/" So I've simply made Tux Paint Config. ALWAYS put quotes around these settings, when writing out a config. file (and trimming them from the start/end, when reading in from a config. file): uifont colorfile savedir exportdir datadir printcommand altprintcommand Similarly, Tux Paint itself will not only run wordexp() on Linux, but will now also trim beginning/end quotes from ALL settings, on ALL [other] platforms. If there are issues, or someone has a better idea, please speak up! As always, please test all this on your favorite OSes to make sure things continue to work as expected. Thanks! -- -bill! Sent from my computer |