Skip to content

Commit

Permalink
DNN-31339 DNN Platform: GetURL API in a file manager impacting CKEdit…
Browse files Browse the repository at this point in the history
…or performance (#2918)
  • Loading branch information
mikebigun authored and mitchelsellers committed Aug 3, 2019
1 parent 1879c67 commit 080afb1
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using DotNetNuke.Common;
using DotNetNuke.Common.Internal;
using DotNetNuke.Common.Utilities;
Expand All @@ -39,7 +38,7 @@ public class StandardFolderProvider : FolderProvider
{
private static readonly ILog Logger = LoggerSource.Instance.GetLogger(typeof(StandardFolderProvider));

private static readonly Regex InvalidFileUrlCharsRegex = new Regex(@"[%;?:@&=+$,]", RegexOptions.Compiled);
private static readonly char[] InvalidFileUrlChars = new char[] { '%', ';', '?', ':', '@', '&', '=', '+', '$', ',' };

#region Public Properties

Expand Down Expand Up @@ -193,13 +192,16 @@ public override string GetFileUrl(IFileInfo file)
{
Requires.NotNull("file", file);

var portalSettings = GetPortalSettings(file.PortalId);
var portalSettings = file.PortalId == PortalSettings.Current?.PortalId ?
PortalSettings.Current :
GetPortalSettings(file.PortalId);

var rootFolder = file.PortalId == Null.NullInteger ? Globals.HostPath : portalSettings.HomeDirectory;

var fullPath = rootFolder + file.Folder + file.FileName;

//check if a filename has a character that is not valid for urls
if (InvalidFileUrlCharsRegex.IsMatch(fullPath))
if (fullPath.IndexOfAny(InvalidFileUrlChars) >= 0)
{
return Globals.LinkClick(String.Format("fileid={0}", file.FileId), Null.NullInteger, Null.NullInteger);
}
Expand Down

0 comments on commit 080afb1

Please sign in to comment.