Skip to content

Commit

Permalink
Fix regression in canonicalizePath on Windows UNC paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Rufflewind committed Jan 23, 2024
1 parent 9893189 commit 28e4eb0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
3 changes: 2 additions & 1 deletion System/Directory/Internal/Windows.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,8 @@ fromExtendedLengthPath ePath' =
| (toChar <$> [c1, c2, c3, c4]) == "\\\\?\\" ->
case path of
c5 : c6 : c7 : subpath@(c8 : _)
| (toChar <$> [c5, c6, c7, c8]) == "UNC\\" -> pack subpath
| (toChar <$> [c5, c6, c7, c8]) == "UNC\\" ->
os "\\" <> pack subpath
drive : col : subpath
-- if the path is not "regular", then the prefix is necessary
-- to ensure the path is interpreted literally
Expand Down
4 changes: 3 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
Changelog for the [`directory`][1] package
==========================================

## 1.3.8.3 (TBD)
## 1.3.8.3 (Jan 2024)

* Relax `Win32` version bounds to support 2.14.0.0.
([#166](https://github.com/haskell/directory/issues/166))
* Fix regression in `canonicalizePath` on Windows UNC paths.
([#170](https://github.com/haskell/directory/issues/170))

## 1.3.8.2 (Dec 2023)

Expand Down
2 changes: 1 addition & 1 deletion directory.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.2
name: directory
version: 1.3.8.2
version: 1.3.8.3
license: BSD-3-Clause
license-file: LICENSE
maintainer: [email protected]
Expand Down
11 changes: 11 additions & 0 deletions tests/CanonicalizePath.hs
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,14 @@ main _t = do
vldn <- canonicalizePath "verylongdirectoryname"
vldn2 <- canonicalizePath "VERYLONGDIRECTORYNAME"
T(expectEq) () vldn vldn2

let isWindows =
#if defined(mingw32_HOST_OS)
True
#else
False
#endif

when isWindows $ do
-- https://github.com/haskell/directory/issues/170
T(expectEq) () "\\\\localhost" =<< canonicalizePath "\\\\localhost"

0 comments on commit 28e4eb0

Please sign in to comment.