From 39d7b9318445e89598a91a4e6137ac28159fe8c4 Mon Sep 17 00:00:00 2001 From: Vamshi Maskuri <117595548+varshith257@users.noreply.github.com> Date: Wed, 11 Sep 2024 18:23:51 +0530 Subject: [PATCH] Fix: Multipart Boundary Generation to Comply with RFC 2046 (#3123) Co-authored-by: asr2003 <162500856+asr2003@users.noreply.github.com> --- .../jvm/src/test/scala/zio/http/BoundarySpec.scala | 11 +++++++++++ .../shared/src/main/scala/zio/http/Boundary.scala | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/zio-http/jvm/src/test/scala/zio/http/BoundarySpec.scala b/zio-http/jvm/src/test/scala/zio/http/BoundarySpec.scala index 52076598e1..47d92220d5 100644 --- a/zio-http/jvm/src/test/scala/zio/http/BoundarySpec.scala +++ b/zio-http/jvm/src/test/scala/zio/http/BoundarySpec.scala @@ -59,6 +59,17 @@ object BoundarySpec extends ZIOHttpSpec { boundary4.isEmpty, ) }, + suite("randomUUID")( + test("generated boundary is RFC 2046 compliant") { + for { + boundary <- Boundary.randomUUID + } yield assertTrue( + boundary.id.matches("^[a-zA-Z0-9-]+$"), + boundary.id.startsWith("----"), + boundary.id.endsWith("----"), + ) + }, + ), ) val spec = suite("BoundarySpec")( diff --git a/zio-http/shared/src/main/scala/zio/http/Boundary.scala b/zio-http/shared/src/main/scala/zio/http/Boundary.scala index 90993f0059..80577a7f7d 100644 --- a/zio-http/shared/src/main/scala/zio/http/Boundary.scala +++ b/zio-http/shared/src/main/scala/zio/http/Boundary.scala @@ -75,6 +75,6 @@ object Boundary { def randomUUID(implicit trace: Trace): zio.UIO[Boundary] = zio.Random.nextUUID.map { id => - Boundary(s"(((${id.toString()})))") + Boundary(s"----${id.toString}----") } }