Skip to content

Fix reporting endpoint URL validation on .NET 10 Linux#2

Draft
MPCoreDeveloper with Copilot wants to merge 3 commits into
masterfrom
copilot/fix-failing-github-actions-job-again
Draft

Fix reporting endpoint URL validation on .NET 10 Linux#2
MPCoreDeveloper with Copilot wants to merge 3 commits into
masterfrom
copilot/fix-failing-github-actions-job-again

Conversation

Copilot AI commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Description

On .NET 10 Linux, Uri.TryCreate("/reports", UriKind.Absolute, out _) returns true because the runtime interprets Unix-style paths as file:// URIs. The validator only checked for "absolute" URIs, so relative paths like /reports silently passed validation and OptionsValidationException was never thrown.

Fix: After Uri.TryCreate succeeds, also assert the scheme is http or https:

// Before — passes on .NET 10 Linux for "/reports" (file:///reports)
else if (!Uri.TryCreate(endpoint.Url, UriKind.Absolute, out _))

// After — rejects file://, relative paths, and any non-web scheme
else if (!Uri.TryCreate(endpoint.Url, UriKind.Absolute, out var parsedUrl) ||
         parsedUrl is null ||
         (parsedUrl.Scheme != Uri.UriSchemeHttps && parsedUrl.Scheme != Uri.UriSchemeHttp))

Changed file: src/SafeWebCore/Infrastructure/NetSecureHeadersOptionsValidator.cs

Related Issue

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Checklist

  • Code follows project coding standards
  • Tests added/updated for changes
  • All tests pass (dotnet test)
  • XML documentation added for public APIs
  • CHANGELOG.md updated

Copilot AI added 2 commits July 25, 2026 19:29
…10 Linux Uri.TryCreate behavior

On .NET 10 Linux, Uri.TryCreate("/reports", UriKind.Absolute, out _) returns true
because it interprets the path as file:///reports. The validator now additionally
checks that the parsed URI has an http or https scheme, ensuring relative paths
and non-web URIs are properly rejected.
Copilot AI changed the title [WIP] Fix failing GitHub Actions job Build, test, and pack Fix reporting endpoint URL validation on .NET 10 Linux Jul 25, 2026
Copilot AI requested a review from MPCoreDeveloper July 25, 2026 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants