fix: CalDAV hrefs with encoded slashes survive the proxy
This commit is contained in:
1 parent
6b6cbe953d
commit
58b3194878
2 files changed
+8
-3
No files matched your search
@@ -63,7 +63,10 @@ public sealed record DavPath(DavKind Kind, Guid? PrincipalId = null, Guid? Calen
|
||||
return new DavPath(DavKind.Unknown);
|
||||
}
|
||||
|
||||
string Decode(string segment) => Uri.UnescapeDataString(segment);
|
||||
// YARP kodiert ein bereits kodiertes %2F beim Weiterleiten erneut (%252F). Ein Schrägstrich ist in UIDs möglich (Importe), ein
|
||||
// wörtliches „%2F“ praktisch nie – daher gilt nach dem Dekodieren verbliebenes %2F als Schrägstrich.
|
||||
static string Decode(string segment) =>
|
||||
Uri.UnescapeDataString(segment).Replace("%2F", "/", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
switch (segments.Length)
|
||||
{
|
||||
|
||||
@@ -57,7 +57,8 @@ public sealed class CalDavTests(AppFixture fixture)
|
||||
using var request = new HttpRequestMessage(method, path);
|
||||
if (body is not null)
|
||||
{
|
||||
request.Content = new StringContent(body, Encoding.UTF8, contentType);
|
||||
request.Content = new StringContent(body, Encoding.UTF8);
|
||||
request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse(contentType);
|
||||
}
|
||||
|
||||
tweak?.Invoke(request);
|
||||
@@ -262,7 +263,8 @@ public sealed class CalDavTests(AppFixture fixture)
|
||||
foreach (var uid in new[] { "abc123@example.com", "uid mit leerzeichen", "a/b:c" })
|
||||
{
|
||||
var href = $"{CalendarPath(calendarId)}{Uri.EscapeDataString(uid).Replace("%40", "@")}.ics";
|
||||
Assert.Equal(HttpStatusCode.Created, (await PutAsync(dav, href, Wrap(Vevent(uid, "Sonderzeichen", day)))).Response.StatusCode);
|
||||
var put = await PutAsync(dav, href, Wrap(Vevent(uid, "Sonderzeichen", day)));
|
||||
Assert.True(put.Response.StatusCode == HttpStatusCode.Created, $"{uid}: {(int)put.Response.StatusCode} {put.Body}");
|
||||
Assert.Contains($"UID:{uid}", (await SendAsync(dav, HttpMethod.Get, href)).Body);
|
||||
|
||||
var listing = await PropFindAsync(dav, CalendarPath(calendarId), 1, "<D:getetag/>");
|
||||
|
||||
Reference in new issue
Block a user