You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am running into an issue where parsed form fields (using .body.asMultipartFormStream) are recognized/decoded as FormField.Text, when Windows browsers (seen with Chrome and Edge) attach files with mimetype application/x-zip-compressed instead of application/zip. This means the binary file data is coerced into a string and mangled and unusable.
The Mediatypes are generated from jshttp which does not include this mimetype, which would be one thing that could address this issue, but there seems to be the intention to fall back to application/octet-stream which however is not happening, instead falling back to a non-binary Text type thereby mangling the data irreversibly.
def parseCustomMediaType(customMediaType: String): Option[MediaType] = {
val contentTypeParts = customMediaType.split('/')
if (contentTypeParts.length == 2) {
val subtypeParts = contentTypeParts(1).split(';')
if (subtypeParts.length >= 1) {
Some(
MediaType(
mainType = contentTypeParts.head,
subType = subtypeParts.head,
parameters = if (subtypeParts.length >= 2) parseOptionalParameters(subtypeParts.tail) else Map.empty,
),
)
} else None
} else None
}
which is going to return a MediaType with binary set to false and not fall back to application/octet-stream.
I do prefer preserving the mimetype the browser set as opposed to setting it to application/octet-stream, since I can deal with that in my app, but the data should IMHO be treated as binary unless certain it really is text.
That would mean that parseCustomMediaType would always explicitly set binary=true if the mimetype does not start with text/ (and possibly other mimetype families known to be text)
The text was updated successfully, but these errors were encountered:
I am running into an issue where parsed form fields (using
.body.asMultipartFormStream
) are recognized/decoded asFormField.Text
, when Windows browsers (seen with Chrome and Edge) attach files with mimetypeapplication/x-zip-compressed
instead ofapplication/zip
. This means the binary file data is coerced into a string and mangled and unusable.The Mediatypes are generated from
jshttp
which does not include this mimetype, which would be one thing that could address this issue, but there seems to be the intention to fall back toapplication/octet-stream
which however is not happening, instead falling back to a non-binary Text type thereby mangling the data irreversibly.Specifically in
FormField.scala
:however in
MediaType.forContentType(...)
:which does:
which is going to return a
MediaType
withbinary
set to false and not fall back toapplication/octet-stream
.I do prefer preserving the mimetype the browser set as opposed to setting it to
application/octet-stream
, since I can deal with that in my app, but the data should IMHO be treated as binary unless certain it really is text.That would mean that
parseCustomMediaType
would always explicitly setbinary=true
if the mimetype does not start withtext/
(and possibly other mimetype families known to be text)The text was updated successfully, but these errors were encountered: