(Translated by https://www.hiragana.jp/)
Segment router errors when looking up empty path string · Issue #209 · metosin/reitit · GitHub
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

Segment router errors when looking up empty path string #209

Closed
svdm opened this issue Jan 25, 2019 · 2 comments
Closed

Segment router errors when looking up empty path string #209

svdm opened this issue Jan 25, 2019 · 2 comments
Labels

Comments

@svdm
Copy link

svdm commented Jan 25, 2019

If SegmentTrie.lookup is called with path being "", it generates an OoB exception inside SegmentTrie.split.

This can happen legitimately when you have a reitit.ring router with a redirect-trailing-slash-handler set to strip. A request to / when no route exists for that path results in the trailing-slash handler stripping "/" to "" and looking that up in the router to see if it can redirect. That works in other routers but not in the segment router.

This might be two separate issues: the trailing-slash handler should probably not look up "" if it can never be a valid route, while segment-router should probably not break on this edge case if other routers do handle it safely.

@ikitommi ikitommi added the bug label Jan 26, 2019
ikitommi added a commit that referenced this issue Jan 26, 2019
@ikitommi
Copy link
Member

Thanks for reporting, fixed the SegmentRouter part in [metosin/reitit "0.2.13"]. The trailing-slash redirecting to "". Did a separate commit out of that. I think it's a bug too, as one could introduce a route with path "", which would get a redirect but all the ring servers add the "/ to uris, so it might go to inifinite redirect loop.

@svdm
Copy link
Author

svdm commented Jan 28, 2019

I can verify it's fixed in 0.2.13, thanks for the quick fix and release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants