https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ea936478f53f3709579726b7112d486458a1734e

commit ea936478f53f3709579726b7112d486458a1734e
Author:     Katayama Hirofumi MZ <katayama.hirofumi...@gmail.com>
AuthorDate: Fri Aug 2 04:16:02 2024 +0900
Commit:     GitHub <nore...@github.com>
CommitDate: Fri Aug 2 04:16:02 2024 +0900

    [BROWSEUI][SHELL32] Fix shell path parsing (#7202)
    
    Fix shell path parsing.
    JIRA issue: CORE-19693
    JIRA issue: CORE-19694
    - Fix CACListISF class by using
      PIDL attributes.
    - Use min macro instead of max
      macro in Shell_ParseSpecialFolder
      function.
---
 dll/win32/browseui/aclistisf.cpp   | 20 +++++++++++++++-----
 dll/win32/shell32/wine/shellpath.c |  2 +-
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/dll/win32/browseui/aclistisf.cpp b/dll/win32/browseui/aclistisf.cpp
index 458ab046b5b..392f6510fea 100644
--- a/dll/win32/browseui/aclistisf.cpp
+++ b/dll/win32/browseui/aclistisf.cpp
@@ -246,9 +246,15 @@ STDMETHODIMP CACListISF::Next(ULONG celt, LPOLESTR *rgelt, 
ULONG *pceltFetched)
             if (!pszRawPath || !pszExpanded)
                 continue;
 
-            if ((m_dwOptions & ACLO_FILESYSDIRS) && 
!PathIsDirectoryW(pszExpanded))
+            DWORD attrs = SFGAO_FOLDER | SFGAO_FILESYSTEM;
+            LPCITEMIDLIST pidlRef = pidlChild;
+            hr = m_pShellFolder->GetAttributesOf(1, &pidlRef, &attrs);
+            if (FAILED_UNEXPECTEDLY(hr))
                 continue;
-            else if ((m_dwOptions & ACLO_FILESYSONLY) && 
!PathFileExistsW(pszExpanded))
+
+            if ((m_dwOptions & ACLO_FILESYSDIRS) && !(attrs & SFGAO_FOLDER))
+                continue;
+            if ((m_dwOptions & (ACLO_FILESYSONLY | ACLO_FILESYSDIRS)) && 
!(attrs & SFGAO_FILESYSTEM))
                 continue;
 
             hr = S_OK;
@@ -339,12 +345,16 @@ STDMETHODIMP CACListISF::Expand(LPCOLESTR pszExpand)
     {
         if (PathIsRelativeW(pszExpand) &&
             SHGetPathFromIDListW(m_pidlCurDir, szPath1) &&
-            PathCombineW(szPath2, szPath1, pszExpand))
+            PathCombineW(szPath2, szPath1, pszExpand) &&
+            PathFileExistsW(szPath2))
         {
             pszExpand = szPath2;
         }
-        GetFullPathNameW(pszExpand, _countof(szPath1), szPath1, NULL);
-        pszExpand = szPath1;
+        else if (PathFileExistsW(pszExpand))
+        {
+            GetFullPathNameW(pszExpand, _countof(szPath1), szPath1, NULL);
+            pszExpand = szPath1;
+        }
     }
 
     CComHeapPtr<ITEMIDLIST> pidl;
diff --git a/dll/win32/shell32/wine/shellpath.c 
b/dll/win32/shell32/wine/shellpath.c
index cd05e1ed010..6537e052a0d 100644
--- a/dll/win32/shell32/wine/shellpath.c
+++ b/dll/win32/shell32/wine/shellpath.c
@@ -1866,7 +1866,7 @@ INT Shell_ParseSpecialFolder(_In_ LPCWSTR pszStart, _Out_ 
LPWSTR *ppch, _Out_ IN
     {
         *ppch = (LPWSTR)(pchBackslash + 1);
         *pcch = (pchBackslash - pszStart) + 1;
-        StrCpyNW(szPath, pszStart, max(*pcch, _countof(szPath)));
+        StrCpyNW(szPath, pszStart, min(*pcch, _countof(szPath)));
         pszPath = szPath;
     }
     else

Reply via email to