Skip to content

PaymentServer/Main.hs uses Data.Text.IO.readFile which is unsafe with respect to locale configuration #74

Open
@exarkun

Description

@exarkun

From https://www.snoyman.com/blog/2020/10/haskell-bad-parts-1:

Locale sensitive file encoding and decoding laughs in our face. When you use Data.Text.IO.readFile, it plays a mind reading game of trying to deduce from clues you don’t care about which character encoding to use. These days, on the vast majority of systems used by native English speakers, this turns out to be UTF-8. So using readFile and writeFile typically “just works.” Using functions from Data.Text.IO looks safe, and can easily get hidden in a large PR or a library dependency.

IOW readFile decodes bytes using an encoding selected based on locale inference (from env vars like LANG and such).

Our use of readFile is just for reading a key file which I guess should always be ASCII but it looks like this may still break if the locale env vars are unset.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions