fix Engine::validatePath() to accept a const ref
This commit is contained in:
parent
67010e02c2
commit
15c30e0d00
@ -249,24 +249,17 @@ void Engine::checkForAllHandlerFunctions()
|
||||
checkForFunction("mouse_motion_event", mouse_motion);
|
||||
}
|
||||
|
||||
bool Engine::validatePath(string & path)
|
||||
bool Engine::validatePath(const string & path)
|
||||
{
|
||||
if (path.find_first_not_of(FILENAME_SAFE_CHARS) != string::npos)
|
||||
if (path[0] == '/')
|
||||
return false;
|
||||
if (path[0] == ':')
|
||||
return false;
|
||||
vector<string> parts = split(path, ':');
|
||||
path = "";
|
||||
bool multiple = false;
|
||||
vector<string> parts = split(path, '/');
|
||||
for (int i = 0, sz = parts.size(); i < sz; i++)
|
||||
{
|
||||
if (parts[i].find_first_not_of(".") != string::npos)
|
||||
{
|
||||
if (multiple)
|
||||
path += "/";
|
||||
path += parts[i];
|
||||
multiple = true;
|
||||
}
|
||||
if (parts[i].find_first_not_of(FILENAME_SAFE_CHARS) != string::npos)
|
||||
return false;
|
||||
if (parts[i].find_first_not_of(".") == string::npos)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ class Engine
|
||||
m_av.setCursorVisible(
|
||||
m_engine_cursor_visible || m_script_cursor_visible);
|
||||
}
|
||||
bool validatePath(std::string & path);
|
||||
bool validatePath(const std::string & path);
|
||||
int getFileSize(const char *fname);
|
||||
|
||||
AV & m_av;
|
||||
|
Loading…
x
Reference in New Issue
Block a user