Skip to content

Commit 7a74dbf

Browse files
committed
Updating IE driver navigation code to be more compliant with W3C spec
1 parent cd66f5a commit 7a74dbf

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

cpp/iedriver/CommandHandlers/GoToUrlCommandHandler.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,28 @@ void GoToUrlCommandHandler::ExecuteInternal(
5353
BOOL is_valid = ::PathIsURL(wide_url.c_str());
5454
if (is_valid != TRUE) {
5555
response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "Specified URL (" + url + ") is not valid.");
56+
return;
57+
}
58+
59+
BOOL is_file_url = ::UrlIsFileUrl(wide_url.c_str());
60+
if (is_file_url) {
61+
DWORD path_length = MAX_PATH;
62+
std::vector<wchar_t> buffer(path_length);
63+
HRESULT hr = ::PathCreateFromUrl(wide_url.c_str(), &buffer[0], &path_length, 0);
64+
if (FAILED(hr)) {
65+
response->SetErrorResponse(ERROR_INVALID_ARGUMENT,
66+
"Specified URL (" + url + ") is a file, " +
67+
"but the path was not valid.");
68+
return;
69+
} else {
70+
std::wstring file_path(&buffer[0]);
71+
if (file_path.size() == 0) {
72+
response->SetErrorResponse(ERROR_INVALID_ARGUMENT,
73+
"Specified URL (" + url + ") is a file, " +
74+
"but the path was not valid.");
75+
return;
76+
}
77+
}
5678
}
5779

5880
status_code = browser_wrapper->NavigateToUrl(url);

0 commit comments

Comments
 (0)