← Back to Pull requests

fix(request): escape literal '+' when rebuilding query parameters #8006

Merged
Duansg merged 2 files (37 lines) on Oct 24, 2026 03:28 UTC
View on GitHub
Duansg Duansg commented on Oct 23, 2026 03:34 UTC
Author

What

When a rule has a parameter config, RequestPlugin rebuilds the query from decoded values with UriUtils.encodeQueryParam, which leaves + unescaped. Because the URI is then built with build(true), a literal plus reaches the upstream as a raw +, and the upstream decodes it as a space.

| Input | Before | After |
|---|---|---|
| q=a%2Bb | q=a+b (decoded as a b) | q=a%2Bb |
| addParameters: c+d | added=c+d (decoded as c d) | added=c%2Bd |

How

After encodeQueryParam, also replace + with %2B for both keys and values. Valueless parameters (null values) are left unchanged.

Scope

  • Only requests whose rule has a parameter config go through this code. Header-only and cookie-only rules, and path encoding, are unchanged.

  • The cost is one String.replace per component, and it allocates nothing when the string has no +.
  • Tests

  • Added RequestPluginTest#testParameterRulePreservesLiteralPlus.

  • shenyu-plugin-request: 33 tests pass, and checkstyle passes.
  • Make sure that:

  • You have read the contribution guidelines.

  • You submit test cases (unit or integration tests) that back your changes.

  • Your local test passed ./mvnw clean install -Dmaven.javadoc.skip=true.
  • Diff: 37 lines (+35 / -2) across 2 files Reviewer: Aias00 Review duration: 1433m
    All Vouch review confidence checks passed
    Residual risk 0.10 = Change Risk (0.26) × (1 − Review Confidence (0.64)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.26 · 37 lines diff across 2 files
    0.26
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.35 · 1 substantive comment(s)
    0.35
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    63%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.218
    Real PR Conversation Timeline
    2 items
    Aias00 Aias00 approved these changes on Oct 23, 2026 06:13 UTC
    Approved Reviewer

    LGTM. UriUtils.encodeQueryParam delegates to encodeUriComponent, whose allowed set for query parameters includes +, so a literal plus survived re-encoding and was decoded as a space upstream. Escaping it to %2B after encoding is correct, and % itself is already encoded to %25, so there is no double-encoding hazard.

    The test covers all three shapes in one assertion set: pre-encoded %2B, a raw + that must become %20, and an added parameter containing +. Good coverage.

    Reviewers
    Assignees
    Duansg Duansg
    Labels
    risk: low confidence: 63.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 26.2% (LOW) · Higher = larger blast radius
    26.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 63.7% · Lower = rushed or shallow review
    63.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 9.5% · Safe to merge
    9.5%
    Repository