Commit 934c76d
Escaping For setBody (#2810)
* fix: compute URL expressions in the target after request flow in the http client interceptor
* refactor(core): use `getAuthority` instead of `getHost` for improved URL handling and modify target configurations
- Introduced `computeDestinationExpressions` to streamline target URL modification logic.
- Improved `DispatchingInterceptor` handling of base path resolution with illegal characters.
- Enhanced `urlEncode` and `pathSeg` utility functions for safety and clarity.
- Refactored `HTTPClientInterceptor` to adjust the target flow and error messages.
- Added extensive URI tests, including custom-parsed and relative path resolution scenarios.
- Updated `applyTargetModifications` for streamlined behavior during request processing.
* feat(core): add URL encoding support for template evaluation in target URLs
- Introduced `TemplateUtil` with a method to check for template markers.
- Enhanced `TemplateExchangeExpression` to support URL encoding for dynamic templates.
- Updated `Target` to skip unnecessary evaluation for URLs without template markers.
- Added extensive tests to verify correct URL encoding across various languages (Groovy, SpEL, XPath, JSONPath).
* docs(roadmap): update URL encoding details for template evaluation in target URLs
- Documented the change to URL encode expressions inside `${}` in target URLs.
- Updated tests to improve validation coverage and logging for clearer output.
* feat(core): optimize expression handling for dynamic URLs with caching
- Introduced a `templateExpressionCache` in `Target` to avoid redundant parsing and compilation of frequently used expressions.
- Improved token parsing and evaluation logic in `TemplateExchangeExpression`, enhancing clarity and performance.
- Renamed test helper method `extracted` to `testExpression` for better readability.
- Updated test cases across multiple classes to cover new enhancements and ensure consistent behavior.
* refactor(core): remove template expression caching from `Target` and simplify logic
- Eliminated `templateExpressionCache` to reduce complexity and improve maintainability.
- Updated `computeDestinationExpressions` to use `Collectors.toList()` for a mutable list.
- Simplified `evaluateTemplate` by removing cache-related logic and comments on minor performance differences.
* feat(core): introduce `Escaping` enum for customizable URL encoding in `Target`
- Added `Escaping` enum with options `NONE`, `URL`, and `SEGMENT` to enhance placeholder escaping in URLs.
- Updated `Target` to include configurable escaping behavior and a helper method `getEscapingFunction()`.
- Extended test cases to validate new escaping options in various scenarios.
* refactor(core): enhance URI handling and extend test coverage
- Updated `URI` to leverage `var` for better readability and added JavaDoc for `resolve` method.
- Improved `ResolverMap` handling of URI schemes, including `classpath:` and `internal:`.
- Added new tests in `HTTPClientInterceptorTest` for complete path computation, including URL encoding.
* feat(core): improve handling of illegal characters in URLs and enhance template evaluation
- Added `UriIllegalCharacterDetector` for validating URI components with RFC 3986 compliance and optional extensions.
- Updated `Target` to skip template evaluation for URLs without placeholders and log warnings for insecure configurations.
- Enhanced `TemplateUtil.containsTemplateMarker` with null safety.
- Improved `RewriteInterceptor` to handle query parsing errors with more informative logging.
- Refactored tests and added new ones to validate changes.
* refactor(core): simplify `URI` logic and enhance test readability
- Refactored `removeLastSegment` method for concise logic using `Math.max()` to avoid redundant checks.
- Replaced `assertEquals(false, ...)` with `assertFalse(...)` for improved readability in tests.
- Cleaned up unused imports in `ResolverMapCombineTest`.
* feat(core): enhance URI handling and replace `pathSeg` with `pathEncode`
- Replaced `pathSeg` method with `pathEncode` for improved naming clarity and functionality in line with RFC 3986.
- Introduced `IPv6Util` for robust validation of IPv6 address text, ensuring only allowed characters are accepted.
- Refactored `Target` to include URL encoding strategy through a dedicated `escapingFunction` and removed redundant logic.
- Streamlined URI combination logic in `ResolverMap` with utility methods for handling slashes and file URIs.
- Added extensive tests covering URL path encoding, IPv6 address validation, and robustification of URI logic for edge cases.
* refactor(core): improve code readability and consistency in URI tests and utilities
- Adjusted visibility modifiers of constants to `final` for better immutability (`URITest`).
- Reordered equality assertion arguments for better readability (`TargetTest`).
- Replaced redundant comments with concise `<p/>` tags in JavaDocs for uniformity.
- Refactored tests to leverage `assertNull` for null comparisons (`FileUtilTest`).
- Removed unused method `stripIpv6BracketsIfNeeded` and redundant imports for cleaner code.
- Enhanced URI combination logic and streamlined utility imports (`DispatchingInterceptor`).
* feat(core): introduce `URIFactory` for enhanced URI creation and add comprehensive RFC 3986 compliance tests
- Added `URIFactory` to support flexible URI creation with options for illegal character handling and backslash escaping.
- Implemented extensive
* test(core): extend URI test cases for edge scenarios in IPv4 and IPv6 parsing
- Added edge case assertions for parsing IPv6 with empty ports.
- Introduced additional checks for IPv4 host and port parsing scenarios.
- Renamed test methods to reflect broader case coverage.
* feat(core): enhance template marker detection and URL evaluation in `Target` and `CallInterceptor`
- Replaced `evaluateExpressions` with `urlIsTemplate` for better semantics and clarity.
- Improved `Target` and `CallInterceptor` to skip URL evaluation when no template markers are present.
- Introduced stricter validation for configurations involving template markers and illegal characters.
- Updated relevant tests to validate changes and added new test cases for URL template evaluation.
* feat(core): add dynamic escaping to `setBody` and improve expression evaluation
- Introduced JSON escaping support for `setBody` based on `contentType`.
- Enhanced `ExchangeExpression` to centralize router retrieval logic.
- Updated tests to include validation logging for transformation scenarios.
- Fixed minor formatting inconsistencies and improved code readability.
* feat(core): add XML escaping support and enhance `getEscapingFunction`
- Introduced XML escaping using `StringEscapeUtils::escapeXml11`.
- Updated `getEscapingFunction` to handle XML content type.
- Added `XML` escaping type to `Escaping` enum.
- Enhanced utility imports and updated dependencies for XML handling.
* test(core): add JSON and Groovy null value handling tests in `SetBodyInterceptorTest`
- Added tests to verify behavior for null values in JSONPath and Groovy expressions.
- Enhanced `SetBodyInterceptorTest` with additional scenarios for content escaping.
- Updated imports for improved code readability and consistency.
* test(core): improve null value handling tests for JSONPath and Groovy in `SetBodyInterceptorTest`
- Refactored tests to consolidate null value handling for JSONPath and Groovy.
- Enhanced `SetBodyInterceptor` to handle `Object` evaluation results, ensuring compatibility and proper type handling.
- Updated helper methods to restructure and reuse test setup across scenarios.
* test(tutorials): log validation errors in `SoapArrayToJsonTutorialTest`
- Added `.log().ifValidationFails()` to improve debugging of failing test scenarios.
---------
Co-authored-by: Christian Gördes <118011644+christiangoerdes@users.noreply.github.com>1 parent eb88166 commit 934c76d
9 files changed
Lines changed: 159 additions & 29 deletions
File tree
- core/src
- main/java/com/predic8/membrane/core
- interceptor/lang
- lang
- util/uri
- test/java/com/predic8/membrane/core
- interceptor
- lang
- templating
- util/xml
- distribution/src/test/java/com/predic8/membrane/tutorials
- soap
- transformation
Lines changed: 25 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
| 21 | + | |
20 | 22 | | |
| 23 | + | |
| 24 | + | |
21 | 25 | | |
22 | 26 | | |
| 27 | + | |
| 28 | + | |
23 | 29 | | |
24 | 30 | | |
25 | 31 | | |
26 | 32 | | |
| 33 | + | |
| 34 | + | |
27 | 35 | | |
28 | 36 | | |
29 | 37 | | |
30 | | - | |
31 | | - | |
| 38 | + | |
32 | 39 | | |
33 | 40 | | |
34 | 41 | | |
| |||
58 | 65 | | |
59 | 66 | | |
60 | 67 | | |
61 | | - | |
| 68 | + | |
62 | 69 | | |
63 | 70 | | |
64 | 71 | | |
65 | | - | |
66 | | - | |
67 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
68 | 79 | | |
69 | 80 | | |
70 | | - | |
71 | 81 | | |
72 | 82 | | |
73 | 83 | | |
| |||
84 | 94 | | |
85 | 95 | | |
86 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
87 | 105 | | |
88 | 106 | | |
89 | 107 | | |
| |||
Lines changed: 9 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
62 | | - | |
63 | 63 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
71 | 75 | | |
72 | 76 | | |
73 | 77 | | |
| |||
Lines changed: 27 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
17 | 23 | | |
| 24 | + | |
18 | 25 | | |
19 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
20 | 30 | | |
21 | 31 | | |
22 | 32 | | |
| |||
30 | 40 | | |
31 | 41 | | |
32 | 42 | | |
| 43 | + | |
| 44 | + | |
33 | 45 | | |
34 | 46 | | |
35 | 47 | | |
36 | 48 | | |
37 | 49 | | |
38 | 50 | | |
39 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
40 | 64 | | |
41 | 65 | | |
42 | 66 | | |
43 | 67 | | |
44 | 68 | | |
45 | 69 | | |
46 | 70 | | |
| 71 | + | |
| 72 | + | |
47 | 73 | | |
48 | 74 | | |
49 | 75 | | |
| |||
Lines changed: 42 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
25 | 28 | | |
26 | 29 | | |
27 | 30 | | |
| |||
37 | 40 | | |
38 | 41 | | |
39 | 42 | | |
40 | | - | |
| 43 | + | |
41 | 44 | | |
42 | 45 | | |
43 | 46 | | |
| |||
57 | 60 | | |
58 | 61 | | |
59 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
60 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
61 | 100 | | |
62 | 101 | | |
63 | 102 | | |
| |||
Lines changed: 39 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | 20 | | |
22 | 21 | | |
23 | 22 | | |
| |||
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
| 87 | + | |
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
96 | | - | |
97 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
| 103 | + | |
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
| 126 | + | |
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
204 | | - | |
| 204 | + | |
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
212 | | - | |
| 212 | + | |
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
226 | | - | |
| 226 | + | |
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
| |||
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
249 | | - | |
250 | | - | |
| 249 | + | |
| 250 | + | |
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
257 | 283 | | |
258 | 284 | | |
259 | 285 | | |
| |||
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
1 | 15 | | |
2 | 16 | | |
3 | 17 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
0 commit comments