Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StringIndexOutOfBoundsException from Uri.Path for path ending with % #1553

Closed
kotatera opened this issue Nov 24, 2017 · 1 comment

Comments

@kotatera
Copy link

@kotatera kotatera commented Nov 24, 2017

Given an invalid URI, e.g.: http://syntages.recipesq.com/author/%CE%B8%CE%B5%CE%AF%CE%B1-%CE%B4%CE%AD%CF%83%CF%80%

After calling:
Uri.Path("/author/%CE%B8%CE%B5%CE%AF%CE%B1-%CE%B4%CE%AD%CF%83%CF%80%")
an exception is thrown:
String index out of range: 50 java.lang.StringIndexOutOfBoundsException: String index out of range: 50 at java.lang.String.charAt(String.java:658) at akka.http.scaladsl.model.Uri$.intValueOfHexChar$1(Uri.scala:723) at akka.http.scaladsl.model.Uri$.intValueOfHexWord$1(Uri.scala:727) at akka.http.scaladsl.model.Uri$.decodeBytes$1(Uri.scala:738) at akka.http.scaladsl.model.Uri$.decode(Uri.scala:744) at akka.http.scaladsl.model.Uri$.decode(Uri.scala:714) at akka.http.scaladsl.model.Uri$Path$.build$1(Uri.scala:512) at akka.http.scaladsl.model.Uri$Path$.apply(Uri.scala:516)

while it should rather be something similar to the exception thrown by Uri("http://syntages.recipesq.com/author/%CE%B8%CE%B5%CE%AF%CE%B1-%CE%B4%CE%AD%CF%83%CF%80%") which is:
Illegal URI reference: Unexpected end of input, expected HEXDIG (line 1, column 87): http://syntages.recipesq.com/author/%CE%B8%CE%B5%CE%AF%CE%B1-%CE%B4%CE%AD%CF%83%CF%80% ^ akka.http.scaladsl.model.IllegalUriException: Illegal URI reference: Unexpected end of input, expected HEXDIG (line 1, column 87): http://syntages.recipesq.com/author/%CE%B8%CE%B5%CE%AF%CE%B1-%CE%B4%CE%AD%CF%83%CF%80%

@raboof raboof added the help wanted label Nov 28, 2017
kencharos pushed a commit to kencharos/akka-http that referenced this issue Dec 3, 2017
* Add percent encoding length check at Uri.decode. Bcause
StringIndexOutOfBoundsException raises when Uri.Path call by illegal
format(ex. %AA%, %AA%1).
* Add test case
@jrudolph jrudolph closed this in 6a6ad30 Dec 4, 2017
@jrudolph jrudolph added this to the 10.0.12 milestone Dec 4, 2017
@jrudolph

This comment has been minimized.

Copy link
Member

@jrudolph jrudolph commented Dec 4, 2017

Fixed by #1553.

@jrudolph jrudolph modified the milestones: 10.0.12, 10.1.0-RC1 Dec 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.