-
-
Notifications
You must be signed in to change notification settings - Fork 799
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
Base64 MIME variant does not ignore white space chars as per RFC2045 #414
Comments
Hmmh. That seems kind of .... wrong to me -- simply ignoring non-alphabet characters would be very likely to simply mask legitimate issues without helping inter-operability... I can understand whitespace being exception.
The other question wrt YAML is something we could perhaps tackle more easily by allowing use of different default Base64 encoding. Would one of |
Quick note: fixes in YAML module (to accept type tag on read, write one when serializing) also includes change to use SnakeYAML's codec so this will be resolved with YAML, to the degree that it will skip whitespace characters. As to JSON, I am sort of torn between allowing inclusion of white space for indentation and not, but just because there is no way to actually enclose unescaped linefeeds in String values, and as such indentation does not make much sense there. So although you can certainly include white space, there isn't much reason to do so: output will not look any better. I will leave this issue open, at any rate, to let other comments be added as necessary. |
Ah. Actually, I think I may know what one problem here is -- as-is, code does not deal properly with trailing white space. So, for specific case of YAML, it seems that there is often a single trailing linefeed (whether it should be there or not I don't know, wrt yaml content model, but it is there....). Also note related issue: FasterXML/jackson-dataformats-text#62 |
Hello,
The Base64 Mime variant is non compliant as per RFC2045 Section 6.8. Base64 Content-Transfer-Encoding, which specifies
With this regard, any character including newline characters and whitespace should not be required to fall on 4 character boundaries.
Sample test case that demonstrates the issues (Note I'm using the Yaml dataformat, since base64 mime encoded documents in json strings with (escaped) newlines seems completely broken regardless of whether newlines fall on 4 char boundary or not).
Input document from "Example 2.23. Various Explicit Tags" from spec (1.1 and 1.2) - http://www.yaml.org/spec/1.2/spec.html
Note that
java.util.Base64.getMimeDecoder()
has no issues decoding this document.Also note that technically speaking the YAML codec should be not using the MIME decoder but another variant, not covered in core. http://yaml.org/type/binary.html specifies that
However the current API does not allow specifying such a custom variant as far as I am aware. This should not have any baring on the test case provided (since the document only consists on the base64 alphabet/whitespace and the document lines are not more than 76 characters).
The text was updated successfully, but these errors were encountered: