Skip to content

Commit

Permalink
Prevent navigation to directories using file:// protocol in IE
Browse files Browse the repository at this point in the history
  • Loading branch information
jimevans committed Mar 5, 2019
1 parent ef515df commit 67e2236
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cpp/iedriver/CommandHandlers/GoToUrlCommandHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void GoToUrlCommandHandler::ExecuteInternal(
return;
}

BOOL is_file_url = ::UrlIsFileUrl(wide_url.c_str());
bool is_file_url = ::UrlIsFileUrl(wide_url.c_str()) == TRUE;
if (is_file_url) {
DWORD path_length = MAX_PATH;
std::vector<wchar_t> buffer(path_length);
Expand All @@ -73,6 +73,13 @@ void GoToUrlCommandHandler::ExecuteInternal(
"Specified URL (" + url + ") is a file, " +
"but the path was not valid.");
return;
} else {
if (::PathIsDirectory(file_path.c_str())) {
response->SetErrorResponse(ERROR_INVALID_ARGUMENT,
"Specified URL (" + url + ") is a directory, " +
"and the browser opens directories outside the browser window.");
return;
}
}
}
}
Expand Down

0 comments on commit 67e2236

Please sign in to comment.