Skip to content

Commit

Permalink
Fix random replacement of http with https in resources (issue #3599)
Browse files Browse the repository at this point in the history
  • Loading branch information
donker authored and bdukes committed Jun 5, 2020
1 parent 76fc4be commit f978d2c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
8 changes: 6 additions & 2 deletions DNN Platform/Library/Entities/Portals/PortalSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -699,15 +699,19 @@ public string GetProperty(string propertyName, string format, CultureInfo format
var isPublic = true;
switch (lowerPropertyName)
{
case "scheme":
propertyNotFound = false;
result = SSLEnabled ? "https" : "http";
break;
case "url":
propertyNotFound = false;
result = PropertyAccess.FormatString(PortalAlias.HTTPAlias, format);
break;
case "fullurl": //return portal alias with protocol
case "fullurl": //return portal alias with protocol - note this depends on HttpContext
propertyNotFound = false;
result = PropertyAccess.FormatString(Globals.AddHTTP(PortalAlias.HTTPAlias), format);
break;
case "passwordreminderurl": //if regsiter page defined in portal settings, then get that page url, otherwise return home page.
case "passwordreminderurl": //if regsiter page defined in portal settings, then get that page url, otherwise return home page. - note this depends on HttpContext
propertyNotFound = false;
var reminderUrl = Globals.AddHTTP(PortalAlias.HTTPAlias);
if (RegisterTabId > Null.NullInteger)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,7 @@ public string GetString(string key, string resourceFileRoot, string language, Po
Logger.WarnFormat("Missing localization key. key:{0} resFileRoot:{1} threadCulture:{2} userlan:{3}", key, resourceFileRoot, Thread.CurrentThread.CurrentUICulture, language);
}

return string.IsNullOrEmpty(resourceValue) ? string.Empty : RemoveHttpUrlsIfSiteisSSLEnabled(portalSettings, resourceValue);
}

private string RemoveHttpUrlsIfSiteisSSLEnabled(PortalSettings portalSettings, string resourceValue)
{

if (portalSettings != null && (portalSettings.SSLEnabled || portalSettings.SSLEnforced))
{
resourceValue = resourceValue.Replace(@"http:", @"https:");
}

return resourceValue;
return string.IsNullOrEmpty(resourceValue) ? string.Empty : resourceValue;
}

/// <summary>
Expand Down

0 comments on commit f978d2c

Please sign in to comment.