Skip to content

Commit ae90cdf

Browse files
Address feedback
1 parent a6bdd95 commit ae90cdf

File tree

5 files changed

+11
-22
lines changed

5 files changed

+11
-22
lines changed

src/ImageSharp.Web.Providers.AWS/Caching/AWSS3StorageCache.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private static async Task<PutBucketResponse> CreateIfNotExistsAsync(
126126
/// <summary>
127127
/// <see href="https://github.com/aspnet/AspNetIdentity/blob/b7826741279450c58b230ece98bd04b4815beabf/src/Microsoft.AspNet.Identity.Core/AsyncHelper.cs"/>
128128
/// </summary>
129-
internal static class AsyncHelper
129+
private static class AsyncHelper
130130
{
131131
private static readonly TaskFactory TaskFactory
132132
= new(

src/ImageSharp.Web/CaseHandlingUriBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public static string Encode(CaseHandling handling, Uri uri)
159159
Uri faux = new(FallbackBaseUri, uri);
160160
return BuildRelative(
161161
handling,
162-
pathBase: PathString.FromUriComponent(faux),
162+
path: PathString.FromUriComponent(faux),
163163
query: QueryString.FromUriComponent(faux));
164164
}
165165
}
@@ -210,7 +210,7 @@ private static void InitializeAbsoluteUriString(Span<char> buffer, (bool Lower,
210210

211211
if (uriParts.Scheme.Length > 0)
212212
{
213-
index = CopyTextToBuffer(buffer, index, uriParts.Scheme.AsSpan());
213+
index = CopyTextToBufferLowerInvariant(buffer, index, uriParts.Scheme.AsSpan());
214214
index = CopyTextToBuffer(buffer, index, Uri.SchemeDelimiter.AsSpan());
215215
}
216216

src/ImageSharp.Web/Commands/QueryCollectionRequestParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public CommandCollection ParseRequestCommands(HttpContext context)
2323
}
2424

2525
CommandCollection transformed = new();
26-
foreach (KeyValuePair<string, StringValues> pair in context.Request.Query)
26+
foreach (KeyValuePair<string, StringValues> pair in query)
2727
{
2828
// Use the indexer for both set and query. This replaces any previously parsed values.
2929
transformed[pair.Key] = pair.Value[pair.Value.Count - 1];

src/ImageSharp.Web/ImageSharpRequestAuthorizationUtilities.cs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -231,25 +231,14 @@ public async Task<string> ComputeHMACAsync(HttpContext context, CommandHandling
231231
/// <summary>
232232
/// Compute a Hash-based Message Authentication Code (HMAC) for request authentication.
233233
/// </summary>
234+
/// <remarks>
235+
/// This method is only called by the middleware and only if required.
236+
/// As such, standard checks are avoided.
237+
/// </remarks>
234238
/// <param name="context">Contains information about the current image request and parsed commands.</param>
235-
/// <param name="handling">The command collection handling.</param>
236239
/// <returns>The computed HMAC.</returns>
237-
internal async Task<string> ComputeHMACAsync(ImageCommandContext context, CommandHandling handling)
238-
{
239-
byte[] secret = this.options.HMACSecretKey;
240-
if (secret is null || secret.Length == 0)
241-
{
242-
return null;
243-
}
244-
245-
CommandCollection commands = this.requestParser.ParseRequestCommands(context.Context);
246-
if (handling == CommandHandling.Sanitize)
247-
{
248-
this.StripUnknownCommands(commands);
249-
}
250-
251-
return await this.options.OnComputeHMACAsync(context, secret);
252-
}
240+
internal Task<string> ComputeHMACAsync(ImageCommandContext context)
241+
=> this.options.OnComputeHMACAsync(context, this.options.HMACSecretKey);
253242

254243
private static void ToComponents(
255244
Uri uri,

src/ImageSharp.Web/Middleware/ImageSharpMiddleware.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ private async Task Invoke(HttpContext httpContext, bool retry)
236236
// Key generation uses string.Create under the hood with very low allocation so should be good enough as a cache key.
237237
hmac = await HMACTokenLru.GetOrAddAsync(
238238
httpContext.Request.GetEncodedUrl(),
239-
_ => this.authorizationUtilities.ComputeHMACAsync(imageCommandContext, CommandHandling.None));
239+
_ => this.authorizationUtilities.ComputeHMACAsync(imageCommandContext));
240240
}
241241

242242
await this.options.OnParseCommandsAsync.Invoke(imageCommandContext);

0 commit comments

Comments
 (0)