diff options
author | Daniel Friesel <derf@finalrewind.org> | 2021-01-24 05:44:17 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2021-01-24 05:44:17 +0100 |
commit | 3ff5371635ae392034ad3905fa03e814dabda98e (patch) | |
tree | 0b94c1f5648e65e04415c5072d1270e84997e354 /src/options.c | |
parent | d72a19e7a3d58a4f9b314559378b17d4a6590c17 (diff) |
Handle URL-encoded components in "feh --start-at file://...."
Closes #584
Diffstat (limited to 'src/options.c')
-rw-r--r-- | src/options.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/options.c b/src/options.c index 0bc1a5e..4744bb0 100644 --- a/src/options.c +++ b/src/options.c @@ -859,11 +859,26 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) */ if (opt.start_list_at && path_is_url(opt.start_list_at) && (strlen(opt.start_list_at) <= 8 || strncmp(opt.start_list_at, "file:///", 8) != 0)) { add_file_to_filelist_recursively(opt.start_list_at, FILELIST_FIRST); + /* + * Otherwise, make "feh --start-at dir/file.jpg" behave like + * "feh --start-at dir/file.jpg dir". + */ } else if (opt.start_list_at && strrchr(opt.start_list_at, '/')) { + /* + * feh can't candle urlencoded path components ("some%20dir" etc). + * Use libcurl to unescape them if --start-at is file://... + */ if (strlen(opt.start_list_at) > 8 && strncmp(opt.start_list_at, "file:///", 8) == 0) { - char *start_at_path = estrdup(opt.start_list_at + 7); - free(opt.start_list_at); - opt.start_list_at = start_at_path; + char *unescaped_path = feh_http_unescape(opt.start_list_at); + if (unescaped_path != NULL) { + free(opt.start_list_at); + opt.start_list_at = estrdup(unescaped_path + 7); + free(unescaped_path); + } else { + char *new_path = estrdup(opt.start_list_at + 7); + free(opt.start_list_at); + opt.start_list_at = new_path; + } } char *target_directory = estrdup(opt.start_list_at); char *filename_start = strrchr(target_directory, '/'); |