Skip to content

Lack of support for non-ASCII characters in cabal sdist #3758

Closed as not planned

Description

@snoyberg

This bug is really based in the tar package, and affects both Stack (commercialhaskell/stack#2549 and commercialhaskell/stack#2557) and cabal-install. Repro steps for cabal-install:

  1. git clone https://github.com/snoyberg/yaml
  2. cd yaml
  3. git checkout yaml/0.8.18.2
  4. cabal sdist
  5. tar xfv dist/yaml-0.8.18.2.tar.gz

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.

Activity

  1. ezyang commented on Sep 2, 2016

    @ezyang
    Contributor

    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.

    See upstream haskell/tar#6

  2. snoyberg commented on Sep 2, 2016

    @snoyberg
    CollaboratorAuthor

    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.

  3. ezyang commented on Sep 2, 2016

    @ezyang
    Contributor

    It certainly puzzled me a while too.

  4. 23Skidoo commented on Sep 2, 2016

    @23Skidoo
    Member

    So this is basically a dupe of haskell/tar#6?

  5. snoyberg commented on Sep 2, 2016

    @snoyberg
    CollaboratorAuthor
  6. snoyberg commented on Sep 2, 2016

    @snoyberg
    CollaboratorAuthor

    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.

  7. 23Skidoo commented on Sep 2, 2016

    @23Skidoo
    Member

    @snoyberg cabal-install does depend on text indirectly (via parsec), so using text is fine.

  8. 23Skidoo commented on Sep 2, 2016

    @23Skidoo
    Member
  9. snoyberg commented on Sep 2, 2016

    @snoyberg
    CollaboratorAuthor

    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.

  10. snoyberg commented on Sep 2, 2016

    @snoyberg
    CollaboratorAuthor

    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.

  11. 23Skidoo commented on Sep 2, 2016

    @23Skidoo
    Member

    @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.

  12. snoyberg commented on Sep 2, 2016

    @snoyberg
    CollaboratorAuthor

    IMO handling that case with UTF8 encoding makes more sense, but best behavior is certainly ambiguous.

  13. 13 remaining items

  14. modified the milestones: 1.24.2.1, 1.24.2.0 on Dec 2, 2016
  15. 23Skidoo commented on Dec 2, 2016

    @23Skidoo
    Member

    Remilestoned.

  16. modified the milestones: 1.24.2.1, 2.0.2 on Dec 4, 2017
  17. modified the milestones: 2.0.2, 2.4 on Aug 29, 2018
  18. modified the milestones: 2.4, 2.4.1 on Sep 17, 2018
  19. modified the milestones: 2.4.1.0, 2.4.2.0 on Apr 26, 2019
  20. modified the milestones: 2.4.2.0, 3.4 on Nov 27, 2019
  21. ulysses4ever commented on Jan 8, 2025

    @ulysses4ever
    Collaborator

    This was a dupe of #2558 which is resolved now (thanks to upstream).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions