From 3320e1a2f0e9a925a1d4274c787f14b3a2fe3b67 Mon Sep 17 00:00:00 2001 From: Benjamin Carleski Date: Fri, 17 Jan 2020 17:22:55 -0800 Subject: [PATCH] Remove unused obsoletes from Umbraco.Web --- .../Web/Mvc/HtmlStringUtilitiesTests.cs | 8 -- .../UserGroupPermissionsCacheRefresher.cs | 31 ------- .../Editors/EditorModelEventManager.cs | 7 +- src/Umbraco.Web/HtmlHelperRenderExtensions.cs | 9 +- src/Umbraco.Web/HtmlStringUtilities.cs | 13 --- .../Install/Models/InstallPackageModel.cs | 23 ----- ...mbracoAntiForgeryAdditionalDataProvider.cs | 91 ------------------- src/Umbraco.Web/Umbraco.Web.csproj | 3 - src/Umbraco.Web/UmbracoContext.cs | 36 -------- 9 files changed, 5 insertions(+), 216 deletions(-) delete mode 100644 src/Umbraco.Web/Cache/UserGroupPermissionsCacheRefresher.cs delete mode 100644 src/Umbraco.Web/Install/Models/InstallPackageModel.cs delete mode 100644 src/Umbraco.Web/Security/UmbracoAntiForgeryAdditionalDataProvider.cs diff --git a/src/Umbraco.Tests/Web/Mvc/HtmlStringUtilitiesTests.cs b/src/Umbraco.Tests/Web/Mvc/HtmlStringUtilitiesTests.cs index 04bd4f6e15..36ddecc676 100644 --- a/src/Umbraco.Tests/Web/Mvc/HtmlStringUtilitiesTests.cs +++ b/src/Umbraco.Tests/Web/Mvc/HtmlStringUtilitiesTests.cs @@ -15,14 +15,6 @@ namespace Umbraco.Tests.Web.Mvc _htmlStringUtilities = new HtmlStringUtilities(); } - [Test] - public void ReplaceLineBreaksWithHtmlBreak() - { - var output = _htmlStringUtilities.ReplaceLineBreaksForHtml("

hello world

hello world\r\nhello world\rhello world\nhello world

").ToString(); - var expected = "

hello world

hello world
hello world
hello world
hello world

"; - Assert.AreEqual(expected, output); - } - [Test] public void TruncateWithElipsis() { diff --git a/src/Umbraco.Web/Cache/UserGroupPermissionsCacheRefresher.cs b/src/Umbraco.Web/Cache/UserGroupPermissionsCacheRefresher.cs deleted file mode 100644 index 37e02a0149..0000000000 --- a/src/Umbraco.Web/Cache/UserGroupPermissionsCacheRefresher.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.ComponentModel; -using Umbraco.Core.Cache; - -namespace Umbraco.Web.Cache -{ - [Obsolete("This is no longer used and will be removed from the codebase in the future")] - [EditorBrowsable(EditorBrowsableState.Never)] - public sealed class UserGroupPermissionsCacheRefresher : CacheRefresherBase - { - public UserGroupPermissionsCacheRefresher(AppCaches appCaches) - : base(appCaches) - { } - - #region Define - - protected override UserGroupPermissionsCacheRefresher This => this; - - public static readonly Guid UniqueId = Guid.Parse("840AB9C5-5C0B-48DB-A77E-29FE4B80CD3A"); - - public override Guid RefresherUniqueId => UniqueId; - - public override string Name => "User Group Permissions Cache Refresher"; - - #endregion - - #region Refresher - - #endregion - } -} diff --git a/src/Umbraco.Web/Editors/EditorModelEventManager.cs b/src/Umbraco.Web/Editors/EditorModelEventManager.cs index 2b3eb278ee..df4c5e4b36 100644 --- a/src/Umbraco.Web/Editors/EditorModelEventManager.cs +++ b/src/Umbraco.Web/Editors/EditorModelEventManager.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; +using System.Collections.Generic; using System.Web.Http.Filters; using Umbraco.Core.Dashboards; using Umbraco.Core.Events; @@ -18,9 +16,6 @@ namespace Umbraco.Web.Editors public static event TypedEventHandler> SendingMemberModel; public static event TypedEventHandler> SendingUserModel; - [Obsolete("Please Use SendingDashboardSlimModel")] - [EditorBrowsable(EditorBrowsableState.Never)] - public static event TypedEventHandler>>> SendingDashboardModel; public static event TypedEventHandler>>> SendingDashboardSlimModel; private static void OnSendingDashboardModel(HttpActionExecutedContext sender, EditorModelEventArgs>> e) diff --git a/src/Umbraco.Web/HtmlHelperRenderExtensions.cs b/src/Umbraco.Web/HtmlHelperRenderExtensions.cs index 4f4d61b4a8..d71f90aab5 100644 --- a/src/Umbraco.Web/HtmlHelperRenderExtensions.cs +++ b/src/Umbraco.Web/HtmlHelperRenderExtensions.cs @@ -8,7 +8,6 @@ using System.Web.Mvc; using System.Web.Mvc.Html; using System.Web.Routing; using Umbraco.Core; -using Umbraco.Core.IO; using Umbraco.Web.Mvc; using Umbraco.Web.Security; using Current = Umbraco.Web.Composing.Current; @@ -862,14 +861,14 @@ namespace Umbraco.Web private static readonly HtmlStringUtilities StringUtilities = new HtmlStringUtilities(); /// - /// Replaces text line breaks with HTML line breaks + /// HTML encodes the text and replaces text line breaks with HTML line breaks. /// /// /// The text. - /// The text with text line breaks replaced with HTML line breaks (
)
- public static IHtmlString ReplaceLineBreaksForHtml(this HtmlHelper helper, string text) + /// The HTML encoded text with text line breaks replaced with HTML line breaks (<br />). + public static IHtmlString ReplaceLineBreaks(this HtmlHelper helper, string text) { - return StringUtilities.ReplaceLineBreaksForHtml(text); + return StringUtilities.ReplaceLineBreaks(text); } /// diff --git a/src/Umbraco.Web/HtmlStringUtilities.cs b/src/Umbraco.Web/HtmlStringUtilities.cs index 4606a58a3a..8d5e8a9071 100644 --- a/src/Umbraco.Web/HtmlStringUtilities.cs +++ b/src/Umbraco.Web/HtmlStringUtilities.cs @@ -3,10 +3,8 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; -using System.Text.RegularExpressions; using System.Web; using HtmlAgilityPack; -using Umbraco.Web.WebApi.Filters; namespace Umbraco.Web { @@ -15,17 +13,6 @@ namespace Umbraco.Web /// public sealed class HtmlStringUtilities { - /// - /// Replaces text line breaks with HTML line breaks - /// - /// The text. - /// The text with text line breaks replaced with HTML line breaks (<br />). - [Obsolete("This method doesn't HTML encode the text. Use ReplaceLineBreaks instead.")] - public HtmlString ReplaceLineBreaksForHtml(string text) - { - return new HtmlString(text.Replace("\r\n", @"
").Replace("\n", @"
").Replace("\r", @"
")); - } - /// /// HTML encodes the text and replaces text line breaks with HTML line breaks. /// diff --git a/src/Umbraco.Web/Install/Models/InstallPackageModel.cs b/src/Umbraco.Web/Install/Models/InstallPackageModel.cs deleted file mode 100644 index 0c7d270033..0000000000 --- a/src/Umbraco.Web/Install/Models/InstallPackageModel.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; - -namespace Umbraco.Web.Install.Models -{ - // TODO: do we need this? - [Obsolete("This is only used for the obsolete controller InstallPackageController")] - [DataContract(Name = "installPackage", Namespace = "")] - public class InstallPackageModel - { - [DataMember(Name = "kitGuid")] - public Guid KitGuid { get; set; } - [DataMember(Name = "packageId")] - public int PackageId { get; set; } - [DataMember(Name = "packageFile")] - public string PackageFile { get; set; } - - } -} diff --git a/src/Umbraco.Web/Security/UmbracoAntiForgeryAdditionalDataProvider.cs b/src/Umbraco.Web/Security/UmbracoAntiForgeryAdditionalDataProvider.cs deleted file mode 100644 index 12d7cce753..0000000000 --- a/src/Umbraco.Web/Security/UmbracoAntiForgeryAdditionalDataProvider.cs +++ /dev/null @@ -1,91 +0,0 @@ -using System; -using Umbraco.Web.Mvc; -using Umbraco.Core; -using System.Web.Helpers; -using System.Web; -using Newtonsoft.Json; -using System.ComponentModel; - -namespace Umbraco.Web.Security -{ - [Obsolete("This is no longer used and will be removed from the codebase in future versions")] - [EditorBrowsable(EditorBrowsableState.Never)] - public class UmbracoAntiForgeryAdditionalDataProvider : IAntiForgeryAdditionalDataProvider - { - private readonly IAntiForgeryAdditionalDataProvider _defaultProvider; - - /// - /// Constructor, allows wrapping a default provider - /// - /// - public UmbracoAntiForgeryAdditionalDataProvider(IAntiForgeryAdditionalDataProvider defaultProvider) - { - _defaultProvider = defaultProvider; - } - - public string GetAdditionalData(HttpContextBase context) - { - return JsonConvert.SerializeObject(new AdditionalData - { - Stamp = DateTime.UtcNow.Ticks, - //this value will be here if this is a BeginUmbracoForms form - Ufprt = context.Items["ufprt"]?.ToString(), - //if there was a wrapped provider, add it's value to the json, else just a static value - WrappedValue = _defaultProvider?.GetAdditionalData(context) ?? "default" - }); - } - - public bool ValidateAdditionalData(HttpContextBase context, string additionalData) - { - if (!additionalData.DetectIsJson()) - return false; //must be json - - AdditionalData json; - try - { - json = JsonConvert.DeserializeObject(additionalData); - } - catch - { - return false; //couldn't parse - } - - if (json.Stamp == default) return false; - - //if there was a wrapped provider, validate it, else validate the static value - var validateWrapped = _defaultProvider?.ValidateAdditionalData(context, json.WrappedValue) ?? json.WrappedValue == "default"; - if (!validateWrapped) - return false; - - var ufprtRequest = context.Request["ufprt"]?.ToString(); - - //if the custom BeginUmbracoForms route value is not there, then it's nothing more to validate - if (ufprtRequest.IsNullOrWhiteSpace() && json.Ufprt.IsNullOrWhiteSpace()) - return true; - - //if one or the other is null then something is wrong - if (!ufprtRequest.IsNullOrWhiteSpace() && json.Ufprt.IsNullOrWhiteSpace()) return false; - if (ufprtRequest.IsNullOrWhiteSpace() && !json.Ufprt.IsNullOrWhiteSpace()) return false; - - if (!UmbracoHelper.DecryptAndValidateEncryptedRouteString(json.Ufprt, out var additionalDataParts)) - return false; - - if (!UmbracoHelper.DecryptAndValidateEncryptedRouteString(ufprtRequest, out var requestParts)) - return false; - - //ensure they all match - return additionalDataParts.Count == requestParts.Count - && additionalDataParts[RenderRouteHandler.ReservedAdditionalKeys.Controller] == requestParts[RenderRouteHandler.ReservedAdditionalKeys.Controller] - && additionalDataParts[RenderRouteHandler.ReservedAdditionalKeys.Action] == requestParts[RenderRouteHandler.ReservedAdditionalKeys.Action] - && additionalDataParts[RenderRouteHandler.ReservedAdditionalKeys.Area] == requestParts[RenderRouteHandler.ReservedAdditionalKeys.Area]; - } - - internal class AdditionalData - { - public string Ufprt { get; set; } - public long Stamp { get; set; } - public string WrappedValue { get; set; } - } - - } -} diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index a273805875..27875a1ab0 100755 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -140,7 +140,6 @@ - @@ -346,7 +345,6 @@ - @@ -722,7 +720,6 @@ - diff --git a/src/Umbraco.Web/UmbracoContext.cs b/src/Umbraco.Web/UmbracoContext.cs index ea8a6d5481..3b00c67b42 100644 --- a/src/Umbraco.Web/UmbracoContext.cs +++ b/src/Umbraco.Web/UmbracoContext.cs @@ -116,23 +116,11 @@ namespace Umbraco.Web /// public IPublishedSnapshot PublishedSnapshot => _publishedSnapshot.Value; - /// - /// Gets the published content cache. - /// - [Obsolete("Use the Content property.")] - public IPublishedContentCache ContentCache => PublishedSnapshot.Content; - /// /// Gets the published content cache. /// public IPublishedContentCache Content => PublishedSnapshot.Content; - /// - /// Gets the published media cache. - /// - [Obsolete("Use the Media property.")] - public IPublishedMediaCache MediaCache => PublishedSnapshot.Media; - /// /// Gets the published media cache. /// @@ -247,30 +235,6 @@ namespace Umbraco.Web return UrlProvider.GetUrl(contentId, mode, culture); } - /// - /// Gets the absolute url of a content identified by its identifier. - /// - /// The content identifier. - /// - /// The absolute url for the content. - [Obsolete("Use the Url() method with UrlMode.Absolute.")] - public string UrlAbsolute(int contentId, string culture = null) - { - return UrlProvider.GetUrl(contentId, UrlMode.Absolute, culture); - } - - /// - /// Gets the absolute url of a content identified by its identifier. - /// - /// The content identifier. - /// - /// The absolute url for the content. - [Obsolete("Use the Url() method with UrlMode.Absolute.")] - public string UrlAbsolute(Guid contentId, string culture = null) - { - return UrlProvider.GetUrl(contentId, UrlMode.Absolute, culture); - } - #endregion private string PreviewToken