You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Lack of support for non-ASCII characters in cabal sdist #3758
Expected: Find a file with the name yaml-0.8.18.2/test/resources/accenté/foo.yaml
Actual: The file is named yaml-0.8.18.2/test/resources/accente^A/foo.yaml
Note that Hackage itself rejects non-ASCII filenames, so this is almost a moot point. However, if cabal sdist properly encodes the file path, Hackage will reject the upload with a useful error message, instead of silently accepting the upload (which happened to me). There may also be an argument to be made that Hackage's filepath checking code should be made a bit more strict I'm not sure.
To be clear, this only applies to cabal sdist, and not cabal act-as-setup -- sdist, because Cabal's code calls the tar program directly which does not have this bug.
I was about to try my hand at a patch for this, but I'm not sure which library to use for the UTF8 encoding. Neither text nor utf8-string appear to be dependencies of cabal-install right now, and I doubt they are desired additions. I suppose an alternative is simply to check the paths to ensure they are ASCII and error out if not.
I was just looking into "fixing it at the source" as well. It seems unclear how to do it. One idea I had is:
Introduce a bytesToTarPath function, which would be defined as bytesToTarPath isDir path = toTarPath isDir (BS.unpack path)
Introduce a toTarPathUtf8 function, which would be defined as toTarPathUtf8 isDir path = bytesToTarPath isDir (encodeUtf8 (T.pack path))
Deprecate toTarPath
I can float this idea over there too. But I'm not too excited about it, since it's just moving the exact same approach I'm recommending here and in Stack to the tar package, and there doesn't seem to be anything better without breaking backwards compatibility.
Actually, this is harder to resolve in cabal-install than it was in Stack, due to usage of the Tar.pack function. So in this case, it probably does make more sense to move the fix upstream.
@snoyberg Since our aim is to make tarballs with unicode fail better, I was thinking about making the tar package fail directly on encountering paths with unicode.
Activity
ezyang commentedon Sep 2, 2016
To be clear, this only applies to
cabal sdist, and notcabal act-as-setup -- sdist, because Cabal's code calls thetarprogram directly which does not have this bug.See upstream haskell/tar#6
snoyberg commentedon Sep 2, 2016
Thank you for the comment, you just unbroke my brain. I couldn't reconcile what I saw in the Cabal source code with the behavior I was experiencing.
ezyang commentedon Sep 2, 2016
It certainly puzzled me a while too.
23Skidoo commentedon Sep 2, 2016
So this is basically a dupe of haskell/tar#6?
snoyberg commentedon Sep 2, 2016
Yes, but it can be worked around inside cabal-install the same way I proposed doing it in Stack, see https://github.com/commercialhaskell/stack/pull/2557/files#diff-7f7c1fa6ec0ee064e1a11c95f5b1b025L110.
snoyberg commentedon Sep 2, 2016
I was about to try my hand at a patch for this, but I'm not sure which library to use for the UTF8 encoding. Neither text nor utf8-string appear to be dependencies of cabal-install right now, and I doubt they are desired additions. I suppose an alternative is simply to check the paths to ensure they are ASCII and error out if not.
23Skidoo commentedon Sep 2, 2016
@snoyberg
cabal-installdoes depend ontextindirectly (viaparsec), so usingtextis fine.23Skidoo commentedon Sep 2, 2016
@snoyberg
Something like this workaround would be acceptable for now, but in the long run we should fix it at the source.
snoyberg commentedon Sep 2, 2016
I was just looking into "fixing it at the source" as well. It seems unclear how to do it. One idea I had is:
bytesToTarPathfunction, which would be defined asbytesToTarPath isDir path = toTarPath isDir (BS.unpack path)toTarPathUtf8function, which would be defined astoTarPathUtf8 isDir path = bytesToTarPath isDir (encodeUtf8 (T.pack path))toTarPathI can float this idea over there too. But I'm not too excited about it, since it's just moving the exact same approach I'm recommending here and in Stack to the tar package, and there doesn't seem to be anything better without breaking backwards compatibility.
snoyberg commentedon Sep 2, 2016
Actually, this is harder to resolve in cabal-install than it was in Stack, due to usage of the
Tar.packfunction. So in this case, it probably does make more sense to move the fix upstream.23Skidoo commentedon Sep 2, 2016
@snoyberg Since our aim is to make tarballs with unicode fail better, I was thinking about making the
tarpackage fail directly on encountering paths with unicode.snoyberg commentedon Sep 2, 2016
IMO handling that case with UTF8 encoding makes more sense, but best behavior is certainly ambiguous.
13 remaining items
23Skidoo commentedon Dec 2, 2016
Remilestoned.
ulysses4ever commentedon Jan 8, 2025
This was a dupe of #2558 which is resolved now (thanks to upstream).