-
Notifications
You must be signed in to change notification settings - Fork 329
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
FIX RefererResult bug #975
Conversation
the url host an invalid referer was returned)
the referer host an invalid referer was returned
…present in" This reverts commit f41182d.
…resent in" This reverts commit fa7065c.
If the context path string was present in the referer host, the getReferer() method returned an invalid referer
On proxied app servers is common to have the context path suppressed from the external URL, although it is still valid within the app server context. If the request referer path does not start with the internal context, it should return the entire path.
Fix referer retrieval bug
|
||
verify(logic).forwardTo(RefererController.class); | ||
verify(controller).index(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too much context to execute a simple check. Maybe it's better to relax visibility of getReferer() to protected and test only this method, what do you think?
and we get an extra extension point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, that was my first commit on VRaptor so I tried to write comprehensive unit tests :-) - but I agree it's too much for something so simple. In addition it's a hard condition to achieve, the strings must match in a little-prob coincidence.
About the extension point, I don't have an opinion - would you expect this class to be extended? If so, then yes it's a good way to maintain its structure (or else people would have to create another method to perform this check, or even put its code within the callers)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your tests are fine =)
it's just that this test class has several tests that could be testing only getReferer(), not the whole redirect or forward methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, I followed the other methods pattern but we could have simple tests which would check if the returned string matches the expected value and we're good to go. Wanna me to change that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, please @valeriolopes! After that change we can merge this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ended up creating another pull request (976); I really need to stop and play with git (we still use svn here). The changes are there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks @valeriolopes. So I think we close this PR, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, looks like the other one embraces everything
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeap! thks
You're right, I followed the other methods pattern but we could have simple tests which would check if the returned string matches the expected value and we're good to go. Wanna me to change that? |
When retrieving the http referer, vraptor uses the substring method to identify the beggining of the context path. If the context path appears in the URL host the return is invalid.
Example: http://application.code.com/app/test/
VRaptor will search '/app' in the URL and will find http://application.code.com/app.test and return /application.code.com/app/test and not /app/test as expected.