diff --git a/akka-http-tests/src/test/scala/akka/http/scaladsl/server/directives/PathDirectivesSpec.scala b/akka-http-tests/src/test/scala/akka/http/scaladsl/server/directives/PathDirectivesSpec.scala index c42cd701c34..da6637b99da 100644 --- a/akka-http-tests/src/test/scala/akka/http/scaladsl/server/directives/PathDirectivesSpec.scala +++ b/akka-http-tests/src/test/scala/akka/http/scaladsl/server/directives/PathDirectivesSpec.scala @@ -208,7 +208,9 @@ class PathDirectivesSpec extends RoutingSpec with Inside { val test = testFor(pathPrefix(JavaUUID) { echoCaptureAndUnmatchedPath }) "accept [/bdea8652-f26c-40ca-8157-0b96a2a8389d]" inThe test("bdea8652-f26c-40ca-8157-0b96a2a8389d:") "accept [/bdea8652-f26c-40ca-8157-0b96a2a8389dyes]" inThe test("bdea8652-f26c-40ca-8157-0b96a2a8389d:yes") - "accept [/00000000-0000-0000-0000-000000000000]" inThe test("00000000-0000-0000-0000-000000000000:") + "accept [/00000000-0000-0000-0000-000000000000]" inThe test("00000000-0000-0000-0000-000000000000:") // nil uuid + "accept [/733a018b-5f16-4699-0e1a-1d3f6f0d0315]" inThe test("733a018b-5f16-4699-0e1a-1d3f6f0d0315:") // variant 0 + "accept [/733a018b-5f16-4699-fe1a-1d3f6f0d0315]" inThe test("733a018b-5f16-4699-fe1a-1d3f6f0d0315:") // future variant "reject [/]" inThe test() "reject [/abc]" inThe test() } diff --git a/akka-http-tests/src/test/scala/akka/http/scaladsl/unmarshalling/UnmarshallingSpec.scala b/akka-http-tests/src/test/scala/akka/http/scaladsl/unmarshalling/UnmarshallingSpec.scala index ec3b541f8a1..12a59c3a681 100644 --- a/akka-http-tests/src/test/scala/akka/http/scaladsl/unmarshalling/UnmarshallingSpec.scala +++ b/akka-http-tests/src/test/scala/akka/http/scaladsl/unmarshalling/UnmarshallingSpec.scala @@ -46,6 +46,14 @@ class UnmarshallingSpec extends FreeSpec with Matchers with BeforeAndAfterAll wi val uuid = UUID.randomUUID() Unmarshal(uuid.toString).to[UUID] should evaluateTo(uuid) } + "uuidUnmarshaller should unmarshal variant 0 uuid" in { + val uuid = UUID.fromString("733a018b-5f16-4699-0e1a-1d3f6f0d0315") + Unmarshal(uuid.toString).to[UUID] should evaluateTo(uuid) + } + "uuidUnmarshaller should unmarshal future variant uuid" in { + val uuid = UUID.fromString("733a018b-5f16-4699-fe1a-1d3f6f0d0315") + Unmarshal(uuid.toString).to[UUID] should evaluateTo(uuid) + } "uuidUnmarshaller should unmarshal nil uuid" in { Unmarshal("00000000-0000-0000-0000-000000000000").to[UUID] should evaluateTo(UUID.fromString("00000000-0000-0000-0000-000000000000")) } diff --git a/akka-http/src/main/scala/akka/http/scaladsl/server/PathMatcher.scala b/akka-http/src/main/scala/akka/http/scaladsl/server/PathMatcher.scala index 660b1d5c679..bf0a1518bc8 100644 --- a/akka-http/src/main/scala/akka/http/scaladsl/server/PathMatcher.scala +++ b/akka-http/src/main/scala/akka/http/scaladsl/server/PathMatcher.scala @@ -486,7 +486,7 @@ trait PathMatchers { * @group pathmatcher */ val JavaUUID: PathMatcher1[UUID] = - PathMatcher("""[\da-fA-F]{8}-[\da-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][\da-fA-F]{3}-[\da-fA-F]{12}|00000000-0000-0000-0000-000000000000""".r) + PathMatcher("""[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}""".r) .map(UUID.fromString) /** diff --git a/akka-http/src/main/scala/akka/http/scaladsl/unmarshalling/PredefinedFromStringUnmarshallers.scala b/akka-http/src/main/scala/akka/http/scaladsl/unmarshalling/PredefinedFromStringUnmarshallers.scala index 84765796d6b..7b6eecd017f 100755 --- a/akka-http/src/main/scala/akka/http/scaladsl/unmarshalling/PredefinedFromStringUnmarshallers.scala +++ b/akka-http/src/main/scala/akka/http/scaladsl/unmarshalling/PredefinedFromStringUnmarshallers.scala @@ -47,7 +47,7 @@ trait PredefinedFromStringUnmarshallers { implicit val uuidFromStringUnmarshaller: Unmarshaller[String, UUID] = { val validUuidPattern = - "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000".r.pattern + """[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}""".r.pattern Unmarshaller.strict[String, UUID] { string => if (validUuidPattern.matcher(string).matches)