[Trac-dev] Request match "precision" in match_request()
2008-08-31 23:35:05 GMT
While working on #4878 (Weird URL handling of additional characters on the end), which asks that requests to e.g. "/timeline/bogus" either return a 404 or a permanent redirect to "/timeline", I've been looking at match patterns in match_request(). This has raised a few questions for which I would like to get some feedback: * Currently, many request handlers match very liberally. For example, any request that matches "/admin.*" will be handled by the admin module, including "/adminlskjdfkljsd". Is this intentional? If not, shouldn't this be fixed? * Many handlers allow a trailing /, for example "/newticket" and "/newticket/". What is the reason for this? Noah has mentioned this being a convenience for people entering URLs that don't know what they are doing. Are there any other reasons? * The "matching precision" is very variable between handlers. Some handlers match only precise URLs (e.g. "/tickets/([0-9]+)$"), others are more graceful (e.g. "/report(?:/([0-9]+))?", which will show the list of available reports for "/report/bogus"). Is there a rule for how precise a match_request() should be? I see two possibilities: * Be strict in what a handler accepts. This has the advantage of giving a more precise answer for malformed URLs (usually a "No handler matched request to ..."). But it is less forgiving for user-entered URLs, and might therefore have usability issues. If this option should be followed, then a trailing / should probably not be accepted.(Continue reading)
RSS Feed