Voeg Api.AndreaSlopFotografie toe met setup-token, proxy-bewuste limiters en ASF-admin-thema
- Core: opt-in ForwardedHeaders:KnownProxies en rate limiters per clientadres (zonder configuratie ongewijzigd gedrag) - Identity: optioneel setup-token (X-Setup-Token), beide setup-endpoints onder de login-limiter, beveiligingsgebeurtenis setup_token_rejected (5007) - Nieuw client-project SlpModularCms.Api.AndreaSlopFotografie (Identity + Availability) met bijbehorende tests - Frontend: thema asf (VITE_THEME), VITE_DEFAULT_LANGUAGE, tokenveld op de setup-pagina - CI: jobs publish/deploy-asf-test achter ASF_TEST_DEPLOY_ENABLED - Fix U1: 301-Location wordt nu percent-encoded (gevonden door de property-test) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -116,8 +116,10 @@ public class WebsitePathResolverPropertyTests(ITestOutputHelper output)
|
||||
return true;
|
||||
}
|
||||
|
||||
// A browser follows the Location as a URL: split path and query there, and the server
|
||||
// sees the path decoded again.
|
||||
var split = first.Location.IndexOf('?');
|
||||
var targetPath = split < 0 ? first.Location : first.Location[..split];
|
||||
var targetPath = Uri.UnescapeDataString(split < 0 ? first.Location : first.Location[..split]);
|
||||
var targetQuery = split < 0 ? null : first.Location[split..];
|
||||
|
||||
return WebsitePathResolver.Resolve(targetPath, targetQuery, Exists) is not WebsiteResolution.Redirect;
|
||||
|
||||
@@ -92,6 +92,18 @@ public class WebsitePathResolverTests
|
||||
public void TrailingSlash_RedirectsToStrippedPath_EvenWhenTargetDoesNotExist(string path, string target) =>
|
||||
Resolve(path).Should().Be(Redirect(target));
|
||||
|
||||
// Regression (found by the property test): the Location is built from the DECODED path and must
|
||||
// be re-encoded, or /a%3Fb/ would redirect to /a?b (another resource), '#' would start a
|
||||
// fragment and non-ASCII would end up raw in a header value.
|
||||
[Theory]
|
||||
[InlineData("/a?b/", "/a%3Fb")]
|
||||
[InlineData("/a#b/", "/a%23b")]
|
||||
[InlineData("/café/", "/caf%C3%A9")]
|
||||
[InlineData("/50%/", "/50%25")]
|
||||
[InlineData("/blog/", "/blog")]
|
||||
public void Redirect_Location_IsPercentEncoded(string decodedPath, string expectedLocation) =>
|
||||
Resolve(decodedPath).Should().Be(Redirect(expectedLocation));
|
||||
|
||||
[Fact]
|
||||
public void TrailingSlash_KeepsQueryString() =>
|
||||
Resolve("/onbekend/", "?a=1").Should().Be(Redirect("/onbekend?a=1"));
|
||||
|
||||
Reference in New Issue
Block a user