Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@gmethvin
Copy link
Member

If the path of the URI is null, it can cause NPEs in the router and in user code. This normally doesn't happen in an HTTP request, but it seems it can happen if you send a URI which does not have a path component defined, for example:

GET mailto:[email protected] HTTP/1.1

It seems appropriate to send a 400 error in this case. I've done that here by throwing an exception.

This was discussed on the mailing list as well: https://groups.google.com/forum/#!topic/play-framework/-bsLA-UTyis.

@marcospereira
Copy link
Member

@gmethvin can we have a test here?

Also, is Akka Server already returning a 400 when path is null?

@gmethvin
Copy link
Member Author

@marcospereira The Akka server has its own parsing logic for the URI so if it doesn't work it would have to be fixed in Akka anyway. I'll test and see but I don't think it's needed for this PR.

@gmethvin
Copy link
Member Author

@marcospereira I don't think we have a facility to easily send raw HTTP requests in tests (where, for example, I can send a malformed URL). I'm going to merge this now since I think it should be in 2.5.3. At worst it changes one type of error (500 because of an NPE somewhere in your code) to another type of error (400)

@gmethvin gmethvin closed this Apr 27, 2016
@gmethvin gmethvin reopened this Apr 27, 2016
@gmethvin gmethvin merged commit ad22900 into playframework:master Apr 27, 2016
@gmethvin gmethvin deleted the null-path branch April 27, 2016 23:35
@gmethvin gmethvin added this to the 2.5.3 milestone Apr 27, 2016
gmethvin added a commit that referenced this pull request Apr 27, 2016
@gmethvin
Copy link
Member Author

2.5.x: 4d24acb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants