Skip to content

Commit

Permalink
Fixed pulb/mailnag#252 by removing charset check from convert function.
Browse files Browse the repository at this point in the history
  • Loading branch information
tikank committed Nov 4, 2024
1 parent da4e90e commit a9df910
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
4 changes: 1 addition & 3 deletions Mailnag/daemon/mails.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2011 - 2021 Patrick Ulbrich <zulu99@gmx.net>
# Copyright 2020 Andreas Angerer
# Copyright 2016, 2018 Timo Kankare <timo.kankare@iki.fi>
# Copyright 2016, 2018, 2024 Timo Kankare <timo.kankare@iki.fi>
# Copyright 2011 Leighton Earl <leighton.earl@gmx.com>
# Copyright 2011 Ralf Hersel <ralf.hersel@gmx.net>
# Copyright 2019 razer <razerraz@free.fr>
Expand Down Expand Up @@ -171,8 +171,6 @@ def _get_header_field(self, msg_dict, key):
# return utf-8 decoded string from multi-part/multi-charset header text
def _convert(self, text):
decoded = decode_header(text)
if not decoded[0][1] or 'unknown' in decoded[0][1]:
decoded = [(decoded[0][0], 'latin-1')]
return str(make_header(decoded))


Expand Down
6 changes: 2 additions & 4 deletions tests/test_mailcollector.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,10 @@ def test_one_account_no_mails():
("=?ISO-8859-1?Q?a?=", "a"),
("=?ISO-8859-1?Q?a?= b", "a b"),
("=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=", "ab"),
("=?ISO-8859-1?Q?a?==?ISO-8859-1?Q?b?=", "ab"),
("=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=", "ab"),
("=?ISO-8859-1?Q?a_b?=", "a b"),
pytest.param(
"a =?ISO-8859-1?Q?b?=", "a b",
marks=pytest.mark.xfail(reason="Bug https://github.com/pulb/mailnag/issues/252")
),
("a =?ISO-8859-1?Q?b?=", "a b"),
]
)
def test_collector_should_parse_subjects_correctly(input_subject, expected_subject):
Expand Down

0 comments on commit a9df910

Please sign in to comment.