konlue opened a new pull request, #7729:
URL: https://github.com/apache/shenyu/pull/7729

   Fixes #7712.
   
   ## Summary
   
   `PathVariableParameterProcessor#processArgument` passes the path-variable 
value directly as the replacement string to `RegExUtils.replaceAll`. Java 
replacement syntax interprets `$n`, `${name}` and backslashes, so a valid 
identifier such as `$1` fails request construction with 
`IndexOutOfBoundsException: No group 1`, while `a\b` is silently rewritten to 
`ab`.
   
   ## Modifications
   
   - Quote the replacement value with `Matcher.quoteReplacement(...)` in both 
the single-string branch and the `Map<String, String>` branch. The pattern is 
unchanged, so matching behaviour stays the same; only the user-supplied value 
is treated literally.
   - Add two parameterized tests (three request templates each) covering the 
dollar-sign and backslash values on both branches.
   
   ## Verifying this change
   
   - [x] Red-green: with the original unquoted replacement restored, the new 
tests fail with `IndexOutOfBoundsException: No group 1` (the symptom reported 
in the issue); with the fix, all cases pass.
   - [x] Targeted tests pass:
   
     ```bash
     ./mvnw -B -ntp -pl shenyu-sdk/shenyu-sdk-spring test 
-Dtest=PathVariableParameterProcessorTest
     ```
     16/16 green.
   
   - [x] Checkstyle passes:
   
     ```bash
     ./mvnw -B -ntp -pl shenyu-sdk/shenyu-sdk-spring checkstyle:check
     ```
     clean.
   
   ## Notes
   
   Percent-encoding of path segments is a separate concern and is intentionally 
not changed here; this PR only stops regex replacement syntax from mangling 
values.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to