mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 16:10:54 +00:00
sysprof-greeter: validate directory existence in debug directory entry
Signed-off-by: varun-r-mallya <varunrmallya@gmail.com>
This commit is contained in:
@ -175,42 +175,22 @@ static void
|
|||||||
on_debug_dir_entry_changed_cb (SysprofGreeter *self,
|
on_debug_dir_entry_changed_cb (SysprofGreeter *self,
|
||||||
SysprofEntryPopover *popover)
|
SysprofEntryPopover *popover)
|
||||||
{
|
{
|
||||||
const char *errstr = NULL;
|
const char *errstr = NULL;
|
||||||
gboolean valid = FALSE;
|
gboolean valid = FALSE;
|
||||||
const char *text;
|
const char *text;
|
||||||
const char *eq;
|
|
||||||
|
|
||||||
g_assert (SYSPROF_IS_GREETER (self));
|
g_assert (SYSPROF_IS_GREETER (self));
|
||||||
g_assert (SYSPROF_IS_ENTRY_POPOVER (popover));
|
g_assert (SYSPROF_IS_ENTRY_POPOVER (popover));
|
||||||
|
|
||||||
text = sysprof_entry_popover_get_text (popover);
|
text = sysprof_entry_popover_get_text (popover);
|
||||||
eq = strchr (text, '=');
|
|
||||||
|
|
||||||
if (!str_empty0 (text) && eq == NULL)
|
if (g_file_test (text, G_FILE_TEST_IS_DIR))
|
||||||
errstr = _("Use KEY=VALUE to set an environment variable");
|
valid = TRUE;
|
||||||
|
else
|
||||||
if (eq != NULL && eq != text)
|
{
|
||||||
{
|
errstr = _("Directory does not exist");
|
||||||
if (g_unichar_isdigit (g_utf8_get_char (text)))
|
goto failure;
|
||||||
{
|
}
|
||||||
errstr = _("Keys may not start with a number");
|
|
||||||
goto failure;
|
|
||||||
|
|
||||||
}
|
|
||||||
for (const char *iter = text; iter < eq; iter = g_utf8_next_char (iter))
|
|
||||||
{
|
|
||||||
gunichar ch = g_utf8_get_char (iter);
|
|
||||||
|
|
||||||
if (!g_unichar_isalnum (ch) && ch != '_')
|
|
||||||
{
|
|
||||||
errstr = _("Keys may only contain alpha-numerics or underline.");
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_ascii_isalpha (*text))
|
|
||||||
valid = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
failure:
|
failure:
|
||||||
sysprof_entry_popover_set_ready (popover, valid);
|
sysprof_entry_popover_set_ready (popover, valid);
|
||||||
|
|||||||
Reference in New Issue
Block a user