diff --git a/zio-http/shared/src/main/scala/zio/http/Body.scala b/zio-http/shared/src/main/scala/zio/http/Body.scala index a72fdce456..9f000e7032 100644 --- a/zio-http/shared/src/main/scala/zio/http/Body.scala +++ b/zio-http/shared/src/main/scala/zio/http/Body.scala @@ -315,10 +315,11 @@ object Body { form: Form, )(implicit trace: Trace): UIO[Body] = form.multipartBytesUUID.map { case (boundary, bytes) => + val validBoundary = boundary.replaceAll("[^a-zA-Z0-9'()+_,-./:=?]", "-") StreamBody( bytes, knownContentLength = None, - Some(Body.ContentType(MediaType.multipart.`form-data`, Some(boundary))), + Some(Body.ContentType(MediaType.multipart.`form-data`, Some(validBoundary))), ) } @@ -466,7 +467,7 @@ object Body { override def isEmpty: Boolean = true - override def toString: String = "Body.empty" + override def toString(): String = "Body.empty" override private[zio] def unsafeAsArray(implicit unsafe: Unsafe): Array[Byte] = Array.empty[Byte] @@ -513,7 +514,7 @@ object Body { override def asStream(implicit trace: Trace): ZStream[Any, Throwable, Byte] = ZStream.unwrap(asChunk.map(ZStream.fromChunk(_))) - override def toString: String = s"Body.fromChunk($data)" + override def toString(): String = s"Body.fromChunk($data)" override private[zio] def unsafeAsArray(implicit unsafe: Unsafe): Array[Byte] = data.toArray @@ -538,7 +539,7 @@ object Body { override def asStream(implicit trace: Trace): ZStream[Any, Throwable, Byte] = ZStream.unwrap(asChunk.map(ZStream.fromChunk(_))) - override def toString: String = s"Body.fromArray($data)" + override def toString(): String = s"Body.fromArray($data)" override private[zio] def unsafeAsArray(implicit unsafe: Unsafe): Array[Byte] = data