Windows: Fix handling of views of filenames containing '%'
This commit is contained in:
parent
ae72e4a62a
commit
a4cf80f460
2 changed files with 14 additions and 3 deletions
|
@ -5,6 +5,8 @@
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
module Annex.View.ViewedFile (
|
module Annex.View.ViewedFile (
|
||||||
ViewedFile,
|
ViewedFile,
|
||||||
MkViewedFile,
|
MkViewedFile,
|
||||||
|
@ -43,10 +45,18 @@ viewedFileFromReference f = concat
|
||||||
|
|
||||||
{- To avoid collisions with filenames or directories that contain
|
{- To avoid collisions with filenames or directories that contain
|
||||||
- '%', and to allow the original directories to be extracted
|
- '%', and to allow the original directories to be extracted
|
||||||
- from the ViewedFile, '%' is escaped to '\%' (and '\' to '\\').
|
- from the ViewedFile, '%' is escaped. )
|
||||||
-}
|
-}
|
||||||
escape :: String -> String
|
escape :: String -> String
|
||||||
escape = replace "%" "\\%" . replace "\\" "\\\\"
|
escape = replace "%" (escchar:'%':[]) . replace [escchar] [escchar, escchar]
|
||||||
|
|
||||||
|
escchar :: Char
|
||||||
|
#ifndef mingw32_HOST_OS
|
||||||
|
escchar = '\\'
|
||||||
|
#else
|
||||||
|
-- \ is path separator on Windows, so instead use !
|
||||||
|
escchar = '!'
|
||||||
|
#endif
|
||||||
|
|
||||||
{- For use when operating already within a view, so whatever filepath
|
{- For use when operating already within a view, so whatever filepath
|
||||||
- is present in the work tree is already a ViewedFile. -}
|
- is present in the work tree is already a ViewedFile. -}
|
||||||
|
@ -61,7 +71,7 @@ dirFromViewedFile = joinPath . drop 1 . sep [] ""
|
||||||
sep l _ [] = reverse l
|
sep l _ [] = reverse l
|
||||||
sep l curr (c:cs)
|
sep l curr (c:cs)
|
||||||
| c == '%' = sep (reverse curr:l) "" cs
|
| c == '%' = sep (reverse curr:l) "" cs
|
||||||
| c == '\\' = case cs of
|
| c == escchar = case cs of
|
||||||
(c':cs') -> sep l (c':curr) cs'
|
(c':cs') -> sep l (c':curr) cs'
|
||||||
[] -> sep l curr cs
|
[] -> sep l curr cs
|
||||||
| otherwise = sep l (c:curr) cs
|
| otherwise = sep l (c:curr) cs
|
||||||
|
|
1
debian/changelog
vendored
1
debian/changelog
vendored
|
@ -10,6 +10,7 @@ git-annex (5.20141220) UNRELEASED; urgency=medium
|
||||||
* bittorrent: Fix locking problem when using addurl file://
|
* bittorrent: Fix locking problem when using addurl file://
|
||||||
* Windows: Fix local rsync filepath munging (fixes 26 test suite failures).
|
* Windows: Fix local rsync filepath munging (fixes 26 test suite failures).
|
||||||
* Windows: Got the rsync special remote working.
|
* Windows: Got the rsync special remote working.
|
||||||
|
* Windows: Fix handling of views of filenames containing '%'
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Mon, 22 Dec 2014 15:16:38 -0400
|
-- Joey Hess <id@joeyh.name> Mon, 22 Dec 2014 15:16:38 -0400
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue