Skip to content

Commit

Permalink
Fix: Multipart Boundary Generation to Comply with RFC 2046 (#3123)
Browse files Browse the repository at this point in the history
Co-authored-by: asr2003 <162500856+asr2003@users.noreply.github.com>
  • Loading branch information
varshith257 and asr2003 authored Sep 11, 2024
1 parent 1f1c776 commit 39d7b93
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions zio-http/jvm/src/test/scala/zio/http/BoundarySpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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")(
Expand Down
2 changes: 1 addition & 1 deletion zio-http/shared/src/main/scala/zio/http/Boundary.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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}----")
}
}

0 comments on commit 39d7b93

Please sign in to comment.