Skip to content

Commit

Permalink
Fixed logic for trimming trailing blank lines for the DKIM relaxed bo…
Browse files Browse the repository at this point in the history
…dy algorithm

Fixes issue #187
  • Loading branch information
jstedfast committed Nov 9, 2015
1 parent f2906ed commit 71abff2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion MimeKit/Cryptography/DkimRelaxedBodyFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ unsafe int Filter (byte* inbuf, int length, byte* outbuf)

if ((*inptr).IsBlank ()) {
LastWasNewLine = false;
IsEmptyLine = false;
//IsEmptyLine = false;
lwsp = true;
} else {
if (lwsp) {
Expand Down
24 changes: 21 additions & 3 deletions UnitTests/DkimRelaxedBodyFilterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,29 @@ namespace UnitTests {
[TestFixture]
public class DkimRelaxedBodyFilterTests
{
// Disabled because it conflicts with TestTrimmingEmptyLines()
// [Test]
// public void TestWhiteSpaceBeforeNewLine ()
// {
// const string text = "This is a test of the relaxed body filter \n \n";
// const string expected = "This is a test of the relaxed body filter\n\n";
// var input = Encoding.ASCII.GetBytes (text);
// var filter = new DkimRelaxedBodyFilter ();
// int outputIndex, outputLength;
// byte[] output;
// string actual;
//
// output = filter.Flush (input, 0, input.Length, out outputIndex, out outputLength);
// actual = Encoding.ASCII.GetString (output, outputIndex, outputLength);
//
// Assert.AreEqual (expected, actual);
// }

[Test]
public void TestWhiteSpaceBeforeNewLine ()
public void TestTrimmingEmptyLines ()
{
const string text = "This is a test of the relaxed body filter \n \n";
const string expected = "This is a test of the relaxed body filter\n\n";
const string text = "Hello!\r\n \r\n\r\n";
const string expected = "Hello!\r\n";
var input = Encoding.ASCII.GetBytes (text);
var filter = new DkimRelaxedBodyFilter ();
int outputIndex, outputLength;
Expand Down

0 comments on commit 71abff2

Please sign in to comment.