dream icon indicating copy to clipboard operation
dream copied to clipboard

`split_target` over string beginning with exactly two slashes

Open cuihtlauac opened this issue 2 years ago • 3 comments

I believe the behaviour of split_target is wrong when it is passed a string which begins with exactly two slashes:

>utop-full -require digestif.c
utop # #require "dream";;
utop # Dream.split_target "aaa/bbb/ccc";;
- : string * string = ("aaa/bbb/ccc", "")
utop # Dream.split_target "/aaa/bbb/ccc";;
- : string * string = ("/aaa/bbb/ccc", "")
utop # Dream.split_target "//aaa/bbb/ccc";; (* Boom! *)
- : string * string = ("/bbb/ccc", "")
utop # Dream.split_target "///aaa/bbb/ccc";;
- : string * string = ("/aaa/bbb/ccc", "")
utop # Dream.split_target "////aaa/bbb/ccc";;
- : string * string = ("//aaa/bbb/ccc", "")
utop # Dream.split_target "/////aaa/bbb/ccc";;
- : string * string = ("///aaa/bbb/ccc", "")

cuihtlauac avatar Jan 27 '23 07:01 cuihtlauac

Maybe an upstream issue:

  • https://github.com/mirage/ocaml-uri/issues/167
  • https://github.com/aantron/dream/blob/master/src/pure/formats.ml#L168

cuihtlauac avatar Jan 27 '23 08:01 cuihtlauac

It's probably related to

https://github.com/aantron/dream/blob/599efd55fc5d0f0f3fbe776fd2ba6b17f6aeca8d/test/expect/pure/formats/target/target.ml#L19-L22

and the test's output

https://github.com/aantron/dream/blob/599efd55fc5d0f0f3fbe776fd2ba6b17f6aeca8d/test/expect/pure/formats/target/target.ml#L37

and may be an upstream issue indeed. I am looking into this now. Ultimately, it should be possible to work around it by reimplementing it, even if it turns out to be an issue in Uri.

aantron avatar Apr 15 '23 05:04 aantron

I've left a detailed comment about this in the issue you opened, https://github.com/mirage/ocaml-uri/issues/167 (thanks for that). I suggest we wait to see if there is a fix for this in ocaml-uri soon. If not, we can work around it in Dream for the next release.

aantron avatar Apr 15 '23 06:04 aantron