Skip to content

Commit 3c5b11e

Browse files
committed
Support Unicode in long file names
1 parent c2c70ce commit 3c5b11e

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Codec/Archive/Tar/LongNames.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ decodeLongNames = go Nothing Nothing
137137
Fail $ Right NoLinkEntryAfterTypeKEntry
138138

139139
otherEntryPayloadToFilePath :: BL.ByteString -> FilePath
140-
otherEntryPayloadToFilePath = B.unpack . B.takeWhile (/= '\0') . BL.toStrict
140+
otherEntryPayloadToFilePath =
141+
fromPosixString . byteToPosixString . B.takeWhile (/= '\0') . BL.toStrict
141142

142143
castEntry :: Entry -> GenEntry FilePath FilePath
143144
castEntry e = e

Codec/Archive/Tar/Types.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ symlinkEntry name targetLink =
288288
longLinkEntry :: FilePath -> GenEntry TarPath linkTarget
289289
longLinkEntry tarpath = Entry {
290290
entryTarPath = TarPath [PS.pstr|././@LongLink|] mempty,
291-
entryContent = OtherEntryType 'L' (LBS.fromStrict $ packAscii tarpath) (fromIntegral $ length tarpath),
291+
entryContent = OtherEntryType 'L' (LBS.fromStrict $ posixToByteString $ toPosixString tarpath) (fromIntegral $ length tarpath),
292292
entryPermissions = ordinaryFilePermissions,
293293
entryOwnership = Ownership "" "" 0 0,
294294
entryTime = 0,
@@ -305,7 +305,7 @@ longLinkEntry tarpath = Entry {
305305
longSymLinkEntry :: FilePath -> GenEntry TarPath linkTarget
306306
longSymLinkEntry linkTarget = Entry {
307307
entryTarPath = TarPath [PS.pstr|././@LongLink|] mempty,
308-
entryContent = OtherEntryType 'K' (LBS.fromStrict . packAscii $ linkTarget) (fromIntegral $ length linkTarget),
308+
entryContent = OtherEntryType 'K' (LBS.fromStrict $ posixToByteString $ toPosixString $ linkTarget) (fromIntegral $ length linkTarget),
309309
entryPermissions = ordinaryFilePermissions,
310310
entryOwnership = Ownership "" "" 0 0,
311311
entryTime = 0,

0 commit comments

Comments
 (0)