From 143b1879cccc222e3a1b39f676d4676b4598ee7a Mon Sep 17 00:00:00 2001 From: roman-yagodin Date: Wed, 29 Jan 2020 09:52:48 +0400 Subject: [PATCH] Don't expose file last modifed date/time via cachebusted URLs Closes #2850 --- DNN Platform/Library/Entities/Portals/PortalSettings.cs | 9 +++------ .../FileSystem/Providers/StandardFolderProvider.cs | 4 +++- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/DNN Platform/Library/Entities/Portals/PortalSettings.cs b/DNN Platform/Library/Entities/Portals/PortalSettings.cs index 2af43d7e151..35bca1c5754 100644 --- a/DNN Platform/Library/Entities/Portals/PortalSettings.cs +++ b/DNN Platform/Library/Entities/Portals/PortalSettings.cs @@ -634,12 +634,9 @@ public string AddCompatibleHttpHeader } } - /* - * add a cachebuster parameter to generated file URI's - * - * of the form ver=[file timestame] ie ver=2015-02-17-162255-735 - * - */ + /// + /// If true then add a cachebuster parameter to generated file URI's. + /// public bool AddCachebusterToResourceUris { get diff --git a/DNN Platform/Library/Services/FileSystem/Providers/StandardFolderProvider.cs b/DNN Platform/Library/Services/FileSystem/Providers/StandardFolderProvider.cs index db3b38d6198..3fd6a59b51b 100644 --- a/DNN Platform/Library/Services/FileSystem/Providers/StandardFolderProvider.cs +++ b/DNN Platform/Library/Services/FileSystem/Providers/StandardFolderProvider.cs @@ -216,7 +216,9 @@ public override string GetFileUrl(IFileInfo file) // Does site management want the cachebuster parameter? if (portalSettings.AddCachebusterToResourceUris) { - return TestableGlobals.Instance.ResolveUrl(fullPath + "?ver=" + file.LastModificationTime.ToString("yyyy-MM-dd-HHmmss-fff")); + var cachebusterToken = UrlUtils.EncryptParameter(file.LastModificationTime.GetHashCode().ToString()); + + return TestableGlobals.Instance.ResolveUrl(fullPath + "?ver=" + cachebusterToken); } return TestableGlobals.Instance.ResolveUrl(fullPath);