From 8160856016e0ed4a4cfa0204f413e9743b32e5de Mon Sep 17 00:00:00 2001 From: Brian Dukes Date: Fri, 12 May 2023 09:45:31 -0500 Subject: [PATCH] Don't prefix icon path if it's rooted Fixes #5641 --- .../Website/admin/Containers/Icon.ascx.cs | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/DNN Platform/Website/admin/Containers/Icon.ascx.cs b/DNN Platform/Website/admin/Containers/Icon.ascx.cs index 5734a6e8678..8d70bb90167 100644 --- a/DNN Platform/Website/admin/Containers/Icon.ascx.cs +++ b/DNN Platform/Website/admin/Containers/Icon.ascx.cs @@ -11,17 +11,16 @@ namespace DotNetNuke.UI.Containers using DotNetNuke.Services.FileSystem; using DotNetNuke.UI.Skins; - /// Project : DotNetNuke - /// Class : DotNetNuke.UI.Containers.Icon - /// /// /// Contains the attributes of an Icon. /// These are read into the PortalModuleBase collection as attributes for the icons within the module controls. /// public partial class Icon : SkinObjectBase { + /// Gets or sets the border width of the icon. public string BorderWidth { get; set; } + /// Gets or sets the CSS class on the img element. public string CssClass { get; set; } /// @@ -42,21 +41,25 @@ protected override void OnLoad(EventArgs e) } this.Visible = false; - if ((this.ModuleControl != null) && (this.ModuleControl.ModuleContext.Configuration != null)) + if (this.ModuleControl?.ModuleContext.Configuration == null) { - var iconFile = this.GetIconFileUrl(); - if (!string.IsNullOrEmpty(iconFile)) - { - if (Globals.IsAdminControl()) - { - iconFile = $"~/DesktopModules/{this.ModuleControl.ModuleContext.Configuration.DesktopModule.FolderName}/{iconFile}"; - } + return; + } + + var iconFile = this.GetIconFileUrl(); + if (string.IsNullOrEmpty(iconFile)) + { + return; + } - this.imgIcon.ImageUrl = iconFile; - this.imgIcon.AlternateText = this.ModuleControl.ModuleContext.Configuration.ModuleTitle; - this.Visible = true; - } + if (!iconFile.StartsWith("~", StringComparison.Ordinal) && Globals.IsAdminControl()) + { + iconFile = $"~/DesktopModules/{this.ModuleControl.ModuleContext.Configuration.DesktopModule.FolderName}/{iconFile}"; } + + this.imgIcon.ImageUrl = iconFile; + this.imgIcon.AlternateText = this.ModuleControl.ModuleContext.Configuration.ModuleTitle; + this.Visible = true; } catch (Exception exc) { @@ -67,7 +70,7 @@ protected override void OnLoad(EventArgs e) private string GetIconFileUrl() { var iconFile = this.ModuleControl.ModuleContext.Configuration.IconFile; - if (string.IsNullOrEmpty(iconFile) || iconFile.StartsWith("~")) + if (string.IsNullOrEmpty(iconFile) || iconFile.StartsWith("~", StringComparison.Ordinal)) { return iconFile; }