Skip to content

Commit

Permalink
Fix boundary (#3)
Browse files Browse the repository at this point in the history
* Update README.md (zio#3120)

Co-authored-by: ZIO Assistant <zio-assistant[bot]@users.noreply.github.com>

* Fix: Ensure multipart boundary is RFC 2046 compliant by sanitizing UUID

* fmt

* Update zio-http/shared/src/main/scala/zio/http/Boundary.scala

Co-authored-by: asr2003 <162500856+asr2003@users.noreply.github.com>

---------

Co-authored-by: zio-assistant[bot] <130037499+zio-assistant[bot]@users.noreply.github.com>
Co-authored-by: ZIO Assistant <zio-assistant[bot]@users.noreply.github.com>
Co-authored-by: asr2003 <162500856+asr2003@users.noreply.github.com>
  • Loading branch information
4 people authored Sep 11, 2024
1 parent 5dde44d commit a011484
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Some of the key features of ZIO HTTP are:
Setup via `build.sbt`:

```scala
libraryDependencies += "dev.zio" %% "zio-http" % "3.0.0-RC10"
libraryDependencies += "dev.zio" %% "zio-http" % "3.0.0"
```

**NOTES ON VERSIONING:**
Expand Down
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 a011484

Please sign in to comment.