Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Fix problem with Invalid non-ASCII or control character in header

KrzysztofPajak5fa6863369e2
diff --git a/src/Web/Grand.Web.Common/Grand.Web.Common.csproj b/src/Web/Grand.Web.Common/Grand.Web.Common.csproj
index 4840afa80..aa35f837c 100644
--- a/src/Web/Grand.Web.Common/Grand.Web.Common.csproj
+++ b/src/Web/Grand.Web.Common/Grand.Web.Common.csproj
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\Build\Grand.Common.props" />
<ItemGroup>
+ <PackageReference Include="Flurl.Http" Version="3.2.0" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="6.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.MongoDb" Version="6.0.1" />
diff --git a/src/Web/Grand.Web.Common/Routing/GrandRedirectResultExecutor.cs b/src/Web/Grand.Web.Common/Routing/GrandRedirectResultExecutor.cs
index e408b940d..fb02c1e4d 100644
--- a/src/Web/Grand.Web.Common/Routing/GrandRedirectResultExecutor.cs
+++ b/src/Web/Grand.Web.Common/Routing/GrandRedirectResultExecutor.cs
@@ -4,7 +4,6 @@ using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.Extensions.Logging;
using System;
-using System.Net;
using System.Threading.Tasks;
namespace Grand.Web.Common.Routing
@@ -45,11 +44,8 @@ namespace Grand.Web.Common.Routing
if (_config.AllowNonAsciiCharInHeaders)
{
- //passed redirect URL may contain non-ASCII characters, that are not allowed now (see https://github.com/aspnet/KestrelHttpServer/issues/1144)
- //so we force to encode this URL before processing
- result.Url = Uri.UnescapeDataString(WebUtility.UrlDecode(result.Url));
+ result.Url = Flurl.Url.EncodeIllegalCharacters(result.Url);
}
-
return base.ExecuteAsync(context, result);
}