Skip to content

Commit

Permalink
Don't prefix icon path if it's rooted
Browse files Browse the repository at this point in the history
Fixes #5641
  • Loading branch information
bdukes committed May 12, 2023
1 parent 23cc594 commit 8160856
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions DNN Platform/Website/admin/Containers/Icon.ascx.cs
Expand Up @@ -11,17 +11,16 @@ namespace DotNetNuke.UI.Containers
using DotNetNuke.Services.FileSystem;
using DotNetNuke.UI.Skins;

/// Project : DotNetNuke
/// Class : DotNetNuke.UI.Containers.Icon
///
/// <summary>
/// Contains the attributes of an Icon.
/// These are read into the PortalModuleBase collection as attributes for the icons within the module controls.
/// </summary>
public partial class Icon : SkinObjectBase
{
/// <summary>Gets or sets the border width of the icon.</summary>
public string BorderWidth { get; set; }

/// <summary>Gets or sets the CSS class on the <c>img</c> element.</summary>
public string CssClass { get; set; }

/// <inheritdoc/>
Expand All @@ -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)
{
Expand All @@ -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;
}
Expand Down

0 comments on commit 8160856

Please sign in to comment.