Skip to content

Conversation

@colindcli
Copy link

@colindcli colindcli commented Dec 3, 2025

User description

#2308 In .NET 4.6.2, URLs do not execute Escape.

#2308


PR Type

Bug fix


Description

  • Fix URL encoding issue in .NET Framework 4.6.2 by enabling dontEscape parameter

  • Add conditional compilation for NETSTANDARD2_0 to handle Uri constructor differences

  • Ensure URLs with special characters (e.g., %3A) are properly escaped across frameworks


Diagram Walkthrough

flowchart LR
  A["URL with special chars<br/>e.g., %3A"] -->|NETSTANDARD2_0| B["Uri constructor<br/>dontEscape=true"]
  A -->|Other frameworks| C["Uri constructor<br/>default behavior"]
  B --> D["Properly escaped URL"]
  C --> D
  D --> E["Correct response<br/>from server"]
Loading

File Walkthrough

Relevant files
Bug fix
UriExtensions.cs
Add dontEscape parameter for .NET Framework URL encoding 

src/RestSharp/Request/UriExtensions.cs

  • Modified MergeBaseUrlAndResource method to pass true as third
    parameter to Uri constructor for NETSTANDARD2_0
  • Modified GetUrlSegmentParamsValues method to pass true as second
    parameter to Uri constructor for NETSTANDARD2_0
  • Added conditional compilation directives to differentiate behavior
    between NETSTANDARD2_0 and other frameworks
  • Ensures proper URL escaping for special characters in .NET Framework
    4.6.2
+10/-2   

@qodo-merge-for-open-source
Copy link
Contributor

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🟡
🎫 #2308
🟢 Fix should work in .NET Framework 4.6.2 environment
URL encoding should be handled properly to prevent 404 NotFound errors
RestSharp should return the same successful response (OK status) as HttpClient when
accessing URLs with special characters like '%3A'
Codebase Duplication Compliance
🟢
No codebase code duplication found No new components were introduced in the PR code
Custom Compliance
🟢
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-merge-for-open-source
Copy link
Contributor

PR Code Suggestions ✨

No code suggestions found for the PR.

@colindcli
Copy link
Author

@dotnet-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant