#2359 Uri.fromStr() Bug

SlimerDude Mon 13 Oct 2014

I believe this to be a bug in the Uri.fromStr(...) method...

Firstly, if I want to encode foo/bar as a URI segment I can do this:

uri := Uri.fromStr("foo\\/bar")
echo(uri)         // --> foo\/bar
echo(uri.encode)  // --> foo%2Fbar

But should I try to encode foo/ I get a ParseErr:

uri := Uri.fromStr("foo\\/")

sys::ParseErr: Invalid Uri: 'foo\/'
  fan.sys.Uri.fromStr (Uri.java:41)
  fan.sys.Uri.fromStr (Uri.java:26)

Whereas I would expect foo/ to be legal and for this to work:

uri := Uri.fromStr("foo\\/")
echo(uri)         // --> foo\/
echo(uri.encode)  // --> foo%2F

brian Mon 20 Oct 2014

Definitely an obscure boundary condition to run across, but good catch. I pushed a fix for that problem.

Login or Signup to reply.