这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@ludusrusso
Copy link
Contributor

@ludusrusso ludusrusso commented Mar 10, 2020

Closes #23

@ludusrusso ludusrusso force-pushed the solve-crlf-end-header-23 branch from 978f565 to f9aee05 Compare March 10, 2020 17:42
@ludusrusso ludusrusso changed the title Solve #23: header with extra black line generated in in some rare cases Solve #23: header with extra blank line generated in in some rare cases Mar 10, 2020
}

func TestFoldHeaderField(t *testing.T) {
header := `DKIM-Signature: a=rsa-sha256; bh=bvW0aiEWdP0ie2rawBb+IiTxlHI9KgEIYjEYTGzMRa0=; c=simple/simple; d=test.xxxxxxxxxx.xxxxx; h=Return-Path:From:To:Subject:Message-ID:Date; s=brisbane; t=1583859773; v=1; b=IIlaZ79pLDdypX2YzJuy9EvxsbrqF360CLhkQqMqVC/GIa1K/X8p8POny7WuVuFTMHLvA1zH9YcXgEgIH+X0GgGsqqzq8ETL+QGZ9g1EKCmIg+ZEYV5JnH25Ar6bJpGra3jg6sIxKi6CthpK50kd8T0Q3K/oZGot4BkLaPqogpo=;`
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a comment among these lines:

The header field length is a multiple of 75. See #23

So that we don't forget about the reason why we have this test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah! Maybe it is better to create a fake header with a minimum length that generates the issue! What do you think?

func TestFoldHeaderField(t *testing.T) {
header := `DKIM-Signature: a=rsa-sha256; bh=bvW0aiEWdP0ie2rawBb+IiTxlHI9KgEIYjEYTGzMRa0=; c=simple/simple; d=test.xxxxxxxxxx.xxxxx; h=Return-Path:From:To:Subject:Message-ID:Date; s=brisbane; t=1583859773; v=1; b=IIlaZ79pLDdypX2YzJuy9EvxsbrqF360CLhkQqMqVC/GIa1K/X8p8POny7WuVuFTMHLvA1zH9YcXgEgIH+X0GgGsqqzq8ETL+QGZ9g1EKCmIg+ZEYV5JnH25Ar6bJpGra3jg6sIxKi6CthpK50kd8T0Q3K/oZGot4BkLaPqogpo=;`
folded := foldHeaderField(header)
if strings.HasSuffix(folded, "\r\n \n") {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, can we just compare the result with the expected result? (Add a string including the \r\n sequences each 75 chars)

That way, if it breaks differently, we'll know too.

@ludusrusso ludusrusso changed the title Solve #23: header with extra blank line generated in in some rare cases Solve #23: header with extra blank line generated in some rare cases Mar 10, 2020
@ludusrusso
Copy link
Contributor Author

The issue is generated when

len(header) % 75 == 74

@ludusrusso ludusrusso force-pushed the solve-crlf-end-header-23 branch from 99b14e1 to 83b409a Compare March 10, 2020 18:08
@codecov-io
Copy link

codecov-io commented Mar 10, 2020

Codecov Report

Merging #24 into master will not change coverage by %.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #24   +/-   ##
=======================================
  Coverage   66.50%   66.50%           
=======================================
  Files           7        7           
  Lines         827      827           
=======================================
  Hits          550      550           
  Misses        208      208           
  Partials       69       69           
Impacted Files Coverage Δ
dkim/header.go 93.10% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 322c864...bf7c84c. Read the comment docs.

@ludusrusso ludusrusso force-pushed the solve-crlf-end-header-23 branch from 83b409a to bf7c84c Compare March 10, 2020 18:09
Copy link
Owner

@emersion emersion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@emersion emersion merged commit 74fc936 into emersion:master Mar 10, 2020
@ludusrusso ludusrusso deleted the solve-crlf-end-header-23 branch March 10, 2020 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dkim: generated header not properly formatted

3 participants