-
Notifications
You must be signed in to change notification settings - Fork 18k
mime: FormatMediaType should quote control characters #7668
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
Labels
Milestone
Comments
Owner changed to @rui314. |
I created https://golang.org/cl/150070043 to fix this issue, but I have some questions about how we want to treat some of the LWS characters. The definition for LWS is: LWS = [CRLF] 1*( SP | HT ) HT, CR, and LF all fall in the 0 - 31 CTL range. I am currently not escaping HT, but still letting it escape CR and LF. It seems the definition of LWS, where it includes CRLF, intends for CRLF to mean CR followed by LF not as individual characters. Does that interpretation seem right? What is the desired behavior here for CR, LF, and HT? |
The manual of the function says "When any of the arguments result in a standard violation then FormatMediaType returns the empty string." If we want to strictly follow that, I think we should return the empty string if we find a stray CR or LF. CR needs to be followed by LF and a space or a tab. One thing I'm not sure if if we really want to be that strict about the standard. Brad, what do you think? |
This is so corner-case that it's hard for me to care one way or another. We could also just return "" from FormatMediaType if we detect any byte from 0x00 - 0x19 and don't even try to escape them. That's a very aggressive option, but I don't think anybody will care or notice, either. I'll let you decide. |
Sorry for the belated response. I've been thinking about this. More I see this issue, more I feel the spec is wrong or pointless at least. For example, in order to include DEL character in a quoted string, one needs to add a backslash before the DEL. But the DEL is transmitted as-is. And, of course, DEL cannot be confused with closing '"'. So what's the point of adding a backslash before the DEL? It's getting seem like a corner case that even the spec doesn't handle that correctly. I'm leaning to leave it alone. |
Content-Type and Content-Transfer-Encoding are defined in RFC 2045:
quoted-string as defined in RFC 2822:
RFC 5322 obsoletes RFC 2822 and defines it in different way:
so as I understand, it basically discourages any non-FWS control characters now. |
Change https://golang.org/cl/154760 mentions this issue: |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: