Reactos

[BROWSEUI] Address Bar: Relative path again! (#8653)

Follow-up of #8633. Relative path parsing.
JIRA issue: CORE-20473
Modify CAddressEditBox::ParseNow.

authored by

Katayama Hirofumi MZ and committed by
GitHub
f96fa0e2 4a7d370d

+34 -6
+34 -6
dll/win32/browseui/addresseditbox.cpp
··· 3 3 * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later) 4 4 * PURPOSE: The combo box of the address band 5 5 * COPYRIGHT: Copyright 2009 Andrew Hill <ash77 at domain reactos.org> 6 - * Copyright 2023-2025 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com> 6 + * Copyright 2023-2026 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com> 7 7 */ 8 8 9 9 #include "precomp.h" ··· 230 230 if (FAILED_UNEXPECTEDLY(hr)) 231 231 goto parseabsolute; 232 232 233 + ATLASSERT(address && address[0]); 234 + 233 235 WCHAR szPath[MAX_PATH], szFullPath[MAX_PATH]; 234 - if (PathIsRelativeW(address) && SHGetPathFromIDListW(pidlCurrent, szPath)) 236 + if (SHGetPathFromIDListW(pidlCurrent, szPath)) // File-system? 235 237 { 236 - PathAppendW(szPath, address); 237 - if (GetFullPathNameW(szPath, _countof(szFullPath), szFullPath, NULL)) 238 + if (PathIsRelativeW(address)) // Relative path? 239 + { 240 + PathAppendW(szPath, address); 241 + if (GetFullPathNameW(szPath, _countof(szFullPath), szFullPath, NULL)) 242 + { 243 + address.Free(); 244 + SHStrDupW(szFullPath, &address); 245 + } 246 + } 247 + else if (address[0] == L'\\' && address[1] != L'\\') // Drive letter omitted? 238 248 { 239 - address.Free(); 240 - SHStrDupW(szFullPath, &address); 249 + // GetFullPathNameW won't resolve drive letter 250 + INT iDrive = PathGetDriveNumberW(szPath); 251 + if (iDrive >= 0) 252 + { 253 + PathBuildRootW(szPath, iDrive); 254 + PathAppendW(szPath, &address[1]); 255 + if (GetFullPathNameW(szPath, _countof(szFullPath), szFullPath, NULL)) 256 + { 257 + address.Free(); 258 + SHStrDupW(szFullPath, &address); 259 + } 260 + } 261 + } 262 + else if (StrChrW(address, L'.') && PathFileExistsW(address)) // Trailing relative path? 263 + { 264 + if (GetFullPathNameW(address, _countof(szFullPath), szFullPath, NULL)) 265 + { 266 + address.Free(); 267 + SHStrDupW(szFullPath, &address); 268 + } 241 269 } 242 270 } 243 271 }