From d723c78228e7b22748c19dae0e12c29f70ddc8c0 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 17 Jul 2012 10:48:30 +0000 Subject: [PATCH] better handling for invalid file extensions (we only support jpg and png) when specified in shot module's save dialog ticket #1160 SVN revision: 73972 --- src/modules/shot/e_mod_main.c | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/src/modules/shot/e_mod_main.c b/src/modules/shot/e_mod_main.c index 4790e6463..cce23efe8 100644 --- a/src/modules/shot/e_mod_main.c +++ b/src/modules/shot/e_mod_main.c @@ -128,28 +128,6 @@ _save_to(const char *file) char *extn = strrchr(file, '.'); char opts[256]; - if (!extn) - { - e_util_dialog_show - (_("Error - Unknown format"), - _("File has an unspecified extension.
" - "Please use '.jpg' or '.png' extensions
" - "only as other formats are not
" - "supported currently.")); - return; - } - if (!((!strcasecmp(extn, ".png")) || - (!strcasecmp(extn, ".jpg")) || - (!strcasecmp(extn, ".jpeg")))) - { - e_util_dialog_show - (_("Error - Unknown format"), - _("File has an unrecognized extension.
" - "Please use '.jpg' or '.png' extensions
" - "only as other formats are not
" - "supported currently.")); - return; - } if (!strcasecmp(extn, ".png")) snprintf(opts, sizeof(opts), "compress=%i", 9); else @@ -200,7 +178,17 @@ _file_select_ok_cb(void *data __UNUSED__, E_Dialog *dia) const char *file; file = e_widget_fsel_selection_path_get(o_fsel); - if (file) _save_to(file); + if ((!file) || (!file[0]) || ((!eina_str_has_extension(file, "jpg")) && (!eina_str_has_extension(file, "png")))) + { + e_util_dialog_show + (_("Error - Unknown format"), + _("File has an unspecified extension.
" + "Please use '.jpg' or '.png' extensions
" + "only as other formats are not
" + "supported currently.")); + return; + } + _save_to(file); if (dia) e_util_defer_object_del(E_OBJECT(dia)); if (win) {