From d2dba72fe33010932e2e2018962c74818023386d Mon Sep 17 00:00:00 2001 From: asr2003 <162500856+asr2003@users.noreply.github.com> Date: Tue, 10 Sep 2024 23:58:13 +0530 Subject: [PATCH] Update Body.scala --- zio-http/shared/src/main/scala/zio/http/Body.scala | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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