-
Notifications
You must be signed in to change notification settings - Fork 122
textproto: check header characters #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
textproto: check header characters #89
Conversation
|
LGTM otherwise. |
4e1b86c to
ce2b371
Compare
Codecov Report
@@ Coverage Diff @@
## master #89 +/- ##
==========================================
- Coverage 79.49% 79.26% -0.24%
==========================================
Files 15 15
Lines 995 1003 +8
==========================================
+ Hits 791 795 +4
- Misses 128 132 +4
Partials 76 76
Continue to review full report at Codecov.
|
|
Question: should
|
Adding enough information to the error message to identify exact field that caused it can help. I agree with your concerns regarding Header.Add. It is unexpected that Header.Add can fail and some people just ignore errors if it gets too verbose and "cannot possibly fail here". |
|
Therefore I think it is a good idea to move check to the formatting time and make error look like "Nth DKIM-Signature value contains invalid characters" |
ce2b371 to
0d51a5f
Compare
|
I moved checks to Regarding rebase to master, in c512562 header type check was moved to a separate function, and I honestly have no idea how keep it clean and informative about what exact header is incorrect |
|
Maybe this? if _, err := w.Write(f.raw()); err != nil {
return fmt.Errorf("failed to write header field #%v (%q): %w", len(h.l) - i, f.k, err)
} |
|
But I wonder if it's a good idea to export |
In your example if rawField, err := f.raw(); err == nil {
if _, err := w.Write(rawField); err != nil {
return err
}
} else {
return fmt.Errorf("failed to write header field #%v (%q): %w", len(h.l) - i, f.k, err)
} |
Add checks for header field name according to RFC 6532 and disallow newline characters in field values.
0d51a5f to
b17a418
Compare
emersion
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Add checks for header field name according to RFC 6532 and disallow newline characters in field values.
Resolves #80