Geary.RFC822.Utils: Ensure best encoding/charset not missing data
By not closing/flushing the buffer, ::get_best_charset and ::get_best_encoding were not including the last line of the buffer, and missing single very long lines when guessing the encoding. Fixes #771
This commit is contained in:
parent
42152d00ba
commit
f3c02c7800
2 changed files with 35 additions and 6 deletions
|
|
@ -10,6 +10,9 @@ class Geary.RFC822.Utils.Test : TestCase {
|
|||
public Test() {
|
||||
base("Geary.RFC822.Utils.Test");
|
||||
add_test("to_preview_text", to_preview_text);
|
||||
add_test("best_encoding_default", best_encoding_default);
|
||||
add_test("best_encoding_long_line", best_encoding_long_line);
|
||||
add_test("best_encoding_binary", best_encoding_binary);
|
||||
}
|
||||
|
||||
public void to_preview_text() throws Error {
|
||||
|
|
@ -21,6 +24,34 @@ class Geary.RFC822.Utils.Test : TestCase {
|
|||
HTML_BODY_EXPECTED);
|
||||
}
|
||||
|
||||
public void best_encoding_default() throws GLib.Error {
|
||||
string test = "abc";
|
||||
var stream = new GMime.StreamMem.with_buffer(test.data);
|
||||
get_best_encoding.begin(stream, 7BIT, null, async_complete_full);
|
||||
var encoding = get_best_encoding.end(async_result());
|
||||
assert_true(encoding == DEFAULT);
|
||||
}
|
||||
|
||||
public void best_encoding_long_line() throws GLib.Error {
|
||||
GLib.StringBuilder buf = new GLib.StringBuilder();
|
||||
for (int i = 0; i < 2000; i++) {
|
||||
buf.append("long ");
|
||||
}
|
||||
var stream = new GMime.StreamMem.with_buffer(buf.str.data);
|
||||
get_best_encoding.begin(stream, 7BIT, null, async_complete_full);
|
||||
var encoding = get_best_encoding.end(async_result());
|
||||
assert_true(encoding == QUOTEDPRINTABLE);
|
||||
}
|
||||
|
||||
public void best_encoding_binary() throws GLib.Error {
|
||||
uint8 test[] = { 0x20, 0x00, 0x20 };
|
||||
var stream = new GMime.StreamMem.with_buffer(test);
|
||||
get_best_encoding.begin(stream, 7BIT, null, async_complete_full);
|
||||
var encoding = get_best_encoding.end(async_result());
|
||||
assert_true(encoding == BASE64);
|
||||
}
|
||||
|
||||
|
||||
public static string PLAIN_BODY_ENCODED = "-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA512\n\n=============================================================================\nFreeBSD-EN-16:11.vmbus Errata Notice\n The FreeBSD Project\n\nTopic: Avoid using spin locks for channel message locks\n\nCategory: core\nModule: vmbus\nAnnounced: 2016-08-12\nCredits: Microsoft OSTC\nAffects: FreeBSD 10.3\nCorrected: 2016-06-15 09:52:01 UTC (stable/10, 10.3-STABLE)\n 2016-08-12 04:01:16 UTC (releng/10.3, 10.3-RELEASE-p7)\n\nFor general information regarding FreeBSD Errata Notices and Security\nAdvisories, including descriptions of the fields above, security\nbranches, and the following sections, please visit\n<URL:https://security.FreeBSD.org/>.\n";
|
||||
public static string PLAIN_BODY_EXPECTED = "FreeBSD-EN-16:11.vmbus Errata Notice The FreeBSD Project Topic: Avoid using spin locks for channel message locks Category: core Module: vmbus Announced: 2016-08-12 Credits: Microsoft OSTC Affects: FreeBSD 10.3 Corrected: 2016-06-15 09:52:01 UTC (stable/10, 10.3-STABLE) 2016-08-12 04:01:16 UTC (releng/10.3, 10.3-RELEASE-p7) For general information regarding FreeBSD Errata Notices and Security Advisories, including descriptions of the fields above, security branches, and the following sections, please visit <URL:https://security.FreeBSD.org/>.";
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue