Skip to content

lstor fails when file name is encoded with UTF-8 #110

@youk

Description

@youk

The below code doesn't handle Unicode strings properly:

values.append("%s" % val)

In case torrent file has __file__ encoded with UTF-8, values ends up having a mixed bag of str and unicode types. join() used afterwards is not supposed to handle this and fails with UnicodeEncodeError:

$ lstor -qo info.name,__file__ Tést.torrent

WARNING Bad metafile 'T\xc3\xa9st.torrent' (UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128))

The problem is the chosen use of "%s" % val which does not yield consistent results encoding-wise.

Test.torrent.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions