Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 5fd1d71

Browse files
[[ Bug 16111 ]] Make 'answer' check if the path is relative before getting full path
1 parent 0c97b7a commit 5fd1d71

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

engine/src/answer.cpp

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -530,11 +530,18 @@ Exec_errors MCAnswer::exec_file(MCExecPoint& ep, const char *p_title)
530530
t_initial_resolved = nil;
531531

532532
if (!t_error && t_initial != nil)
533-
{
534-
// IM-2014-08-06: [[ Bug 13096 ]] Allow file dialogs to work with relative paths by resolving to absolute
535-
t_initial_resolved = MCS_get_canonical_path(t_initial);
536-
if (nil == t_initial_resolved)
537-
t_error == EE_NO_MEMORY;
533+
{
534+
// We only want to resolve the path if the path is relative (otherwise
535+
// it will be created at the current folder - which is /Applications)
536+
if (strchr(t_initial, '/'))
537+
{
538+
// IM-2014-08-06: [[ Bug 13096 ]] Allow file dialogs to work with relative paths by resolving to absolute
539+
t_initial_resolved = MCS_get_canonical_path(t_initial);
540+
if (nil == t_initial_resolved)
541+
t_error = EE_NO_MEMORY;
542+
}
543+
else
544+
t_initial_resolved = strclone(t_initial);
538545
}
539546

540547
if (!t_error)
@@ -596,11 +603,18 @@ Exec_errors MCAnswer::exec_folder(MCExecPoint& ep, const char *p_title)
596603
t_initial_resolved = nil;
597604

598605
if (!t_error && t_initial != nil)
599-
{
600-
// IM-2014-08-06: [[ Bug 13096 ]] Allow file dialogs to work with relative paths by resolving to absolute
601-
t_initial_resolved = MCS_get_canonical_path(t_initial);
602-
if (nil == t_initial_resolved)
603-
t_error == EE_NO_MEMORY;
606+
{
607+
// We only want to resolve the path if the path is relative (otherwise
608+
// it will be created at the current folder - which is /Applications)
609+
if (strchr(t_initial, '/'))
610+
{
611+
// IM-2014-08-06: [[ Bug 13096 ]] Allow file dialogs to work with relative paths by resolving to absolute
612+
t_initial_resolved = MCS_get_canonical_path(t_initial);
613+
if (nil == t_initial_resolved)
614+
t_error = EE_NO_MEMORY;
615+
}
616+
else
617+
t_initial_resolved = strclone(t_initial);
604618
}
605619

606620
if (!t_error)

0 commit comments

Comments
 (0)