From e1432cfe4cee7483ce7b48fc50c3c9293b126ff5 Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Wed, 8 May 2013 20:25:10 +0000 Subject: Improvements to the package importing feature - test case will follow llvm-svn: 181461 --- lldb/source/Interpreter/ScriptInterpreterPython.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'lldb/source/Interpreter/ScriptInterpreterPython.cpp') diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp index 3206154224b..5a4fa625a0a 100644 --- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp +++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp @@ -2602,13 +2602,23 @@ ScriptInterpreterPython::LoadScriptingModule (const char* pathname, Locker::AcquireLock | (init_session ? Locker::InitSession : 0), Locker::FreeAcquiredLock | (init_session ? Locker::TearDownSession : 0)); - if (target_file.GetFileType() == FileSpec::eFileTypeInvalid || - target_file.GetFileType() == FileSpec::eFileTypeUnknown || - target_file.GetFileType() == FileSpec::eFileTypeDirectory ) + if (target_file.GetFileType() == FileSpec::eFileTypeDirectory) { - // if not a filename, try to just plain import + // for directories, just import basename = pathname; } + else if (target_file.GetFileType() == FileSpec::eFileTypeInvalid || + target_file.GetFileType() == FileSpec::eFileTypeUnknown) + { + // if not a valid file of any sort, check if it might be a filename still + // dot can't be used but / and \ can, and if either is found, reject + if (strchr(pathname,'\\') || strchr(pathname,'/')) + { + error.SetErrorString("invalid pathname"); + return false; + } + basename = pathname; // not a filename, probably a package of some sort, let it go through + } else { const char* directory = target_file.GetDirectory().GetCString(); -- cgit v1.2.3