Skip to content

Commit

Permalink
Avoid validating antiforgery for non form data content types
Browse files Browse the repository at this point in the history
  • Loading branch information
javiercn committed May 8, 2024
1 parent 7a211fb commit 16c62e1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,22 @@ private async Task<RequestValidationState> ValidateRequestAsync(HttpContext cont
// want to run the form handling logic against the error page.
context.Features.Get<IExceptionHandlerFeature>() == null;

Check failure on line 165 in src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux Musl ARM64)

src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs#L165

src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs(165,1): error IDE2000: (NETCORE_ENGINEERING_TELEMETRY=Build) Avoid multiple blank lines (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide2000)

Check failure on line 165 in src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux ARM)

src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs#L165

src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs(165,1): error IDE2000: (NETCORE_ENGINEERING_TELEMETRY=Build) Avoid multiple blank lines (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide2000)

Check failure on line 165 in src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux ARM64)

src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs#L165

src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs(165,1): error IDE2000: (NETCORE_ENGINEERING_TELEMETRY=Build) Avoid multiple blank lines (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide2000)

Check failure on line 165 in src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux Musl ARM)

src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs#L165

src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs(165,1): error IDE2000: (NETCORE_ENGINEERING_TELEMETRY=Build) Avoid multiple blank lines (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide2000)

Check failure on line 165 in src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: macOS arm64)

src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs#L165

src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs(165,1): error IDE2000: (NETCORE_ENGINEERING_TELEMETRY=Build) Avoid multiple blank lines (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide2000)

Check failure on line 165 in src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux x64)

src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs#L165

src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs(165,1): error IDE2000: (NETCORE_ENGINEERING_TELEMETRY=Build) Avoid multiple blank lines (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide2000)

Check failure on line 165 in src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: Linux Musl x64)

src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs#L165

src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs(165,1): error IDE2000: (NETCORE_ENGINEERING_TELEMETRY=Build) Avoid multiple blank lines (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide2000)

Check failure on line 165 in src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs

View check run for this annotation

Azure Pipelines / aspnetcore-quarantined-pr (Tests: Ubuntu x64)

src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs#L165

src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs(165,1): error IDE2000: (NETCORE_ENGINEERING_TELEMETRY=Build) Avoid multiple blank lines (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide2000)

Check failure on line 165 in src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Test: Ubuntu x64)

src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs#L165

src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs(165,1): error IDE2000: (NETCORE_ENGINEERING_TELEMETRY=Build) Avoid multiple blank lines (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide2000)

Check failure on line 165 in src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Build: macOS x64)

src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs#L165

src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs(165,1): error IDE2000: (NETCORE_ENGINEERING_TELEMETRY=Build) Avoid multiple blank lines (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide2000)

Check failure on line 165 in src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs

View check run for this annotation

Azure Pipelines / aspnetcore-ci (Build Test: macOS)

src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs#L165

src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs(165,1): error IDE2000: (NETCORE_ENGINEERING_TELEMETRY=Build) Avoid multiple blank lines (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide2000)

Check failure on line 165 in src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs

View check run for this annotation

Azure Pipelines / aspnetcore-quarantined-pr (Tests: macOS)

src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs#L165

src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs(165,1): error IDE2000: (NETCORE_ENGINEERING_TELEMETRY=Build) Avoid multiple blank lines (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide2000)

if (processPost)
{
var valid = false;
if (!context.Request.HasFormContentType)
{
context.Response.StatusCode = StatusCodes.Status400BadRequest;
if (context.RequestServices.GetService<IHostEnvironment>()?.IsDevelopment() == true)
{
await context.Response.WriteAsync("The request has an incorrect Content-type.");
}
return RequestValidationState.InvalidPostRequest;
}

// Respect the token validation done by the middleware _if_ it has been set, otherwise
// run the validation here.
var valid = false;
if (context.Features.Get<IAntiforgeryValidationFeature>() is { } antiForgeryValidationFeature)
{
if (!antiForgeryValidationFeature.IsValid)
Expand Down

0 comments on commit 16c62e1

Please sign in to comment.