Skip to content

Commit 4023189

Browse files
committed
Fix: License info now shows on diagnostic page, and watermarks happen in both imageflow and regular pipelines.
1 parent bb69e57 commit 4023189

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

core/packages.lock.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
".NETFramework,Version=v4.7.2": {
55
"Imazen.Common": {
66
"type": "Direct",
7-
"requested": "[0.9.0-rc01, )",
8-
"resolved": "0.9.0-rc01",
9-
"contentHash": "Zbkh2XBLxZ688CvZSnrPYsQyyFTR93G9cCgwYNHQ1zOzz38rV5Np2+2x+sJNiFvUsKC7sFeT78uHbvPzyQtgaA==",
7+
"requested": "[0.9.0-rc02, )",
8+
"resolved": "0.9.0-rc02",
9+
"contentHash": "jrAiQZFKA6QL2JFF/y6k8P06RkY4miRP4NTEUPvcw/NOZ1G9/rzDXdSWNnaHVHgkFSepHLrUj+sxNsVXvI2NPg==",
1010
"dependencies": {
1111
"Microsoft.Extensions.Hosting.Abstractions": "2.2.0"
1212
}

plugins/ImageResizer.Plugins.Licensing/LicensingPlugin.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace ImageResizer.Plugins.Licensing
3939
// ReSharper disable once UnusedTypeParameter
4040
#pragma warning disable CS0618
4141
internal class LicenseEnforcer : BuilderExtension, IPlugin, IIssueProvider,
42-
ILicenseDiagnosticsProvider, ILicenseConfig, IIssueReceiver, IDiagnosticsHeaderProvider
42+
ILicenseDiagnosticsProvider, ILicenseConfig, IIssueReceiver, IDiagnosticsHeaderProvider, IDiagnosticsProvider, IDiagnosticsProviderFactory
4343
{
4444

4545
public static void EnsureInstalled(Configuration.Config c)
@@ -257,10 +257,10 @@ void ThrowLicenseException(HttpRequest? request)
257257

258258
void Pipeline_PostRewrite(IHttpModule sender, HttpContext? context, ImageResizer.Configuration.IUrlEventArgs e)
259259
{
260-
// Server-side cache-breaker
261-
if (e.QueryString["red_dot"] != "true" && ShouldWatermark(context?.Request))
260+
// Server-side cache-breaker (and, for Imageflow, causes the red dot to be drawn)
261+
if (e.QueryString["watermark_red_dot"] != "true" && ShouldWatermark(context?.Request))
262262
{
263-
e.QueryString["red_dot"] = "true";
263+
e.QueryString["watermark_red_dot"] = "true";
264264
}
265265
ThrowLicenseException(context?.Request);
266266
this.FireHeartbeat();
@@ -284,11 +284,13 @@ protected override RequestedAction PostFlushChanges(ImageState s)
284284
// No watermarking requested, or no bitmap to draw on
285285
return RequestedAction.None;
286286
}
287+
// We're using the System.Drawing system, so we draw the red dot watermark here.
288+
// Not called when Imageflow is used, as it has its own watermarking system.
287289
_watermark.EnsureDrawn(s.destBitmap);
288290
return RequestedAction.None;
289291
}
290292

291-
public object GetDiagnosticsProvider() => Result;
293+
public object GetDiagnosticsProvider() => this;
292294

293295

294296
public void AcceptIssue(IIssue i)
@@ -383,11 +385,11 @@ public string EnforcementMethodMessage
383385
return LicenseEnforcement switch
384386
{
385387
Imazen.Common.Licensing.LicenseErrorAction.Watermark =>
386-
"You are using EnforceLicenseWith.RedDotWatermark. If there is a licensing error, an red dot will be drawn on the bottom-right corner of each image. This can be set to EnforceLicenseWith.Http402Error instead (valuable if you are externally caching or storing result images.)",
388+
"You are using licenseError=\"watermark\" / EnforceLicenseWith.RedDotWatermark . If there is a licensing error, a red dot will be drawn on the bottom-right corner of each image. This can be set to EnforceLicenseWith.Http402Error instead (valuable if you are externally caching or storing result images.)",
387389
Imazen.Common.Licensing.LicenseErrorAction.Http422 =>
388-
"You are using EnforceLicenseWith.Http422Error. If there is a licensing error, HTTP status code 422 will be returned instead of serving the image. This can also be set to EnforceLicenseWith.RedDotWatermark.",
390+
"You are using licenseError=\"exception\" / EnforceLicenseWith.Http422Error. If there is a licensing error, HTTP status code 422 will be returned instead of serving the image. This can also be set to licenseError=\"watermark\" or EnforceLicenseWith.RedDotWatermark.",
389391
Imazen.Common.Licensing.LicenseErrorAction.Http402 =>
390-
"You are using EnforceLicenseWith.Http402Error. If there is a licensing error, HTTP status code 402 will be returned instead of serving the image. This can also be set to EnforceLicenseWith.RedDotWatermark.",
392+
"You are using licenseError=\"exception\" / EnforceLicenseWith.Http402Error. If there is a licensing error, HTTP status code 402 will be returned instead of serving the image. This can also be set to licenseError=\"watermark\" or EnforceLicenseWith.RedDotWatermark.",
391393
_ => throw new ArgumentOutOfRangeException()
392394
};
393395
}
@@ -437,6 +439,11 @@ private string[] GetLicenseCacheDirectories()
437439
}
438440

439441
public string ProvideDiagnosticsHeader()
442+
{
443+
return Result.ProvidePublicLicensesPage(); //Result.GetPublicLicenseHeader();
444+
}
445+
446+
public string ProvideDiagnostics()
440447
{
441448
return Result.ProvideDiagnostics();
442449
}

0 commit comments

Comments
 (0)