[MAGNOLIA-2967] Handle regex non-matching group errors in RegexpVirtualURIMapping - can block the system Created: 11/Dec/09 Updated: 23/Jan/13 Resolved: 17/Dec/09 |
|
| Status: | Closed |
| Project: | Magnolia |
| Component/s: | core |
| Affects Version/s: | 4.2.1 |
| Fix Version/s: | 4.1.4, 4.2.3, 4.3 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Ryan Gardner | Assignee: | Magnolia International |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Template: |
|
| Patch included: |
Yes
|
| Acceptance criteria: |
Empty
|
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
| Bug DoR: |
[ ]*
Steps to reproduce, expected, and actual results filled
[ ]*
Affected version filled
|
| Testcase included: |
Yes
|
| Date of First Response: |
| Description |
|
If the from URI doesn't have as many groups as the to URI is expecting, the regex matcher used by the RegexpVirtualURIMapping will throw an exception that kills the processing of the request. When I accidently removed and saved a VirtualURIFilter config with a blank from URI and a to: URI that was expecting a regex, group - it became impossible for me to fix it via the admin UI: The stacktrace looked a bit like this - java.lang.IndexOutOfBoundsException: No group 1 The attached patch adds a unit test for the kind of bad configuration, and prior to catching the exception and returning an unchanged URL, the test will fail. This may not be the best way to handle this problem in the long term, but if you would argue that making the server become entirely unresponsive and not allow the user to fix a simple typo is a better approach than trapping the exception and returning a URI that is unchanged from the request, I question how much you like your users I thought about making it throw a custom MalformedURIConfig exception and then catching that exception at the VirtualURIFilter level, but since there aren't already testcases existing for the VirtualURIManager or the VirtualURIFilter, I didn't. |
| Comments |
| Comment by Ryan Gardner [ 11/Dec/09 ] |
|
making the title make it more clear that it deals with VirtualURI stuff |
| Comment by Magnolia International [ 17/Dec/09 ] |
|
Thanks Ryan, much appreciated ! Patch applied (slightly differently - return null in case of error, much like other mappings return null when they can't match) |