Commit fb2fee4
fix(rest-api): unwrap WebApplicationException from JasperException in rules include endpoint (#34888)
Tomcat/Jasper wraps any Throwable raised inside a JSP in a ServletException
before it leaves RequestDispatcher.include(), so the dedicated
catch(WebApplicationException) added in #35337 never matched at runtime and
/api/portlet/rules/include kept returning HTTP 200 with debug HTML instead
of the expected 400/404. The generic catch in BaseRestPortlet.getJspResponse()
now walks the cause chain and re-throws the WebApplicationException so JAX-RS
can map the proper status. Added unit tests that simulate the real Jasper
wrapping (the existing test mocked the dispatcher to throw the exception
directly, bypassing the wrapper).
Also in include.jsp:
- Validate the id parameter against UUIDUtil.isUUID before hitting the API,
so an invalid format returns 400 instead of 404.
- Add DEBUG logging on every rejection branch; only log the id value once
it has passed UUID validation, to avoid CWE-117 log injection from the
unvalidated query parameter.
Refs: #34888
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 855c7d5 commit fb2fee4
3 files changed
Lines changed: 75 additions & 0 deletions
File tree
- dotCMS/src
- main
- java/com/dotcms/rest
- webapp/WEB-INF/jsp/rules
- test/java/com/dotcms/rest
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
124 | 134 | | |
125 | 135 | | |
126 | 136 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| |||
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| 17 | + | |
15 | 18 | | |
16 | 19 | | |
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
20 | 23 | | |
21 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
22 | 34 | | |
23 | 35 | | |
24 | 36 | | |
25 | 37 | | |
| 38 | + | |
26 | 39 | | |
27 | 40 | | |
28 | 41 | | |
| |||
31 | 44 | | |
32 | 45 | | |
33 | 46 | | |
| 47 | + | |
34 | 48 | | |
35 | 49 | | |
36 | 50 | | |
| |||
Lines changed: 51 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
109 | 160 | | |
110 | 161 | | |
111 | 162 | | |
| |||
0 commit comments