From 52f4a831397b94d41675cabf8777b735a69e9c2f Mon Sep 17 00:00:00 2001 From: Chris R Date: Fri, 30 Oct 2015 13:30:11 -0700 Subject: [PATCH] React to WebEncoders changes. --- .../HtmlLocalizer.cs | 11 +- .../HtmlLocalizerFactory.cs | 8 +- .../Internal/MvcLocalizationServices.cs | 5 +- .../HelperResult.cs | 12 +-- src/Microsoft.AspNet.Mvc.Razor/RazorPage.cs | 18 ++-- .../RazorTextWriter.cs | 6 +- src/Microsoft.AspNet.Mvc.Razor/RazorView.cs | 8 +- .../RazorViewFactory.cs | 6 +- .../TagHelpers/UrlResolutionTagHelper.cs | 10 +- .../ImageTagHelper.cs | 4 +- .../Internal/JavaScriptStringArrayEncoder.cs | 6 +- .../LinkTagHelper.cs | 16 +-- .../ScriptTagHelper.cs | 18 ++-- .../TagHelperContentExtensions.cs | 8 +- .../Rendering/HtmlString.cs | 4 +- .../Rendering/IHtmlHelper.cs | 10 +- .../Rendering/MvcForm.cs | 6 +- .../Rendering/TagBuilder.cs | 8 +- .../ViewFeatures/DefaultHtmlGenerator.cs | 12 +-- .../ViewFeatures/HtmlHelper.cs | 20 ++-- .../ViewFeatures/HtmlHelperOfT.cs | 14 +-- .../StringCollectionTextWriter.cs | 12 +-- .../ViewFeatures/StringHtmlContent.cs | 6 +- .../MvcEncodedTestFixtureOfT.cs | 8 +- ...Site.HtmlGeneration_Home.Link.Encoded.html | 32 +++--- ...te.HtmlGeneration_Home.Script.Encoded.html | 18 ++-- .../HtmlLocalizerTest.cs | 8 +- ...lizationServiceCollectionExtensionsTest.cs | 21 ++-- .../RazorPageActivatorTest.cs | 18 ++-- .../RazorPageTest.cs | 36 +++---- .../RazorTextWriterTest.cs | 46 ++++---- .../RazorViewFactoryTest.cs | 4 +- .../RazorViewTest.cs | 102 +++++++++--------- .../TagHelpers/UrlResolutionTagHelperTest.cs | 4 +- .../FormTagHelperTest.cs | 2 +- .../ImageTagHelperTest.cs | 10 +- .../LinkTagHelperTest.cs | 48 ++++----- .../ScriptTagHelperTest.cs | 62 +++++------ .../TestableHtmlGenerator.cs | 2 +- .../HtmlContentUtilities.cs | 6 +- .../TestHtmlEncoder.cs | 27 ----- .../TestJavaScriptEncoder.cs | 27 ----- .../TestUrlEncoder.cs | 27 ----- .../Rendering/DefaultTemplatesUtilities.cs | 16 +-- .../Rendering/HtmlHelperCheckboxTest.cs | 2 +- .../Rendering/HtmlHelperFormTest.cs | 4 +- .../Rendering/HtmlHelperSelectTest.cs | 8 +- .../Rendering/HtmlStringTest.cs | 2 +- .../Rendering/TagBuilderTest.cs | 5 +- .../ViewComponentTests.cs | 4 +- .../DefaultEditorTemplatesTest.cs | 8 +- .../ViewFeatures/DefaultHtmlGeneratorTest.cs | 4 +- .../StringCollectionTextWriterTest.cs | 4 +- .../ViewFeatures/StringHtmlContentTest.cs | 2 +- .../TagHelpers/HiddenTagHelper.cs | 6 +- .../AuthorizeBasicMiddleware.cs | 4 +- 56 files changed, 361 insertions(+), 444 deletions(-) delete mode 100644 test/Microsoft.AspNet.Mvc.TestCommon/TestHtmlEncoder.cs delete mode 100644 test/Microsoft.AspNet.Mvc.TestCommon/TestJavaScriptEncoder.cs delete mode 100644 test/Microsoft.AspNet.Mvc.TestCommon/TestUrlEncoder.cs diff --git a/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizer.cs b/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizer.cs index e565fa4f7d..1cbf91ed29 100644 --- a/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizer.cs +++ b/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizer.cs @@ -5,9 +5,8 @@ using System; using System.Collections.Generic; using System.Globalization; using System.Text; +using System.Text.Encodings.Web; using Microsoft.Extensions.Localization; -using Microsoft.Extensions.WebEncoders; - namespace Microsoft.AspNet.Mvc.Localization { @@ -18,14 +17,14 @@ namespace Microsoft.AspNet.Mvc.Localization public class HtmlLocalizer : IHtmlLocalizer { private IStringLocalizer _localizer; - private readonly IHtmlEncoder _encoder; + private readonly HtmlEncoder _encoder; /// /// Creates a new . /// /// The to read strings from. - /// The . - public HtmlLocalizer(IStringLocalizer localizer, IHtmlEncoder encoder) + /// The . + public HtmlLocalizer(IStringLocalizer localizer, HtmlEncoder encoder) { if (localizer == null) { @@ -266,7 +265,7 @@ namespace Microsoft.AspNet.Mvc.Localization { if (tokenBuffer != null && tokenBuffer.Length > 0) { - outputBuffer.Append(_encoder.HtmlEncode(string.Format(tokenBuffer.ToString(), arguments))); + outputBuffer.Append(_encoder.Encode(string.Format(tokenBuffer.ToString(), arguments))); } } } diff --git a/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizerFactory.cs b/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizerFactory.cs index 0e3d80e5a5..81e8d8f74a 100644 --- a/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizerFactory.cs +++ b/src/Microsoft.AspNet.Mvc.Localization/HtmlLocalizerFactory.cs @@ -2,8 +2,8 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Text.Encodings.Web; using Microsoft.Extensions.Localization; -using Microsoft.Extensions.WebEncoders; namespace Microsoft.AspNet.Mvc.Localization { @@ -13,14 +13,14 @@ namespace Microsoft.AspNet.Mvc.Localization public class HtmlLocalizerFactory : IHtmlLocalizerFactory { private readonly IStringLocalizerFactory _factory; - private readonly IHtmlEncoder _encoder; + private readonly HtmlEncoder _encoder; /// /// Creates a new . /// /// The . - /// The . - public HtmlLocalizerFactory(IStringLocalizerFactory localizerFactory, IHtmlEncoder encoder) + /// The . + public HtmlLocalizerFactory(IStringLocalizerFactory localizerFactory, HtmlEncoder encoder) { if (localizerFactory == null) { diff --git a/src/Microsoft.AspNet.Mvc.Localization/Internal/MvcLocalizationServices.cs b/src/Microsoft.AspNet.Mvc.Localization/Internal/MvcLocalizationServices.cs index 00bc30336a..9736baccae 100644 --- a/src/Microsoft.AspNet.Mvc.Localization/Internal/MvcLocalizationServices.cs +++ b/src/Microsoft.AspNet.Mvc.Localization/Internal/MvcLocalizationServices.cs @@ -3,6 +3,7 @@ using System; using System.Linq; +using System.Text.Encodings.Web; using Microsoft.AspNet.Mvc.Razor; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; @@ -27,9 +28,9 @@ namespace Microsoft.AspNet.Mvc.Localization.Internal services.TryAdd(ServiceDescriptor.Singleton()); services.TryAdd(ServiceDescriptor.Transient(typeof(IHtmlLocalizer<>), typeof(HtmlLocalizer<>))); services.TryAdd(ServiceDescriptor.Transient()); - if (!services.Any(sd => sd.ServiceType == typeof(IHtmlEncoder))) + if (!services.Any(sd => sd.ServiceType == typeof(HtmlEncoder))) { - services.TryAdd(ServiceDescriptor.Instance(HtmlEncoder.Default)); + services.TryAdd(ServiceDescriptor.Instance(HtmlEncoder.Default)); } services.AddLocalization(setupAction); diff --git a/src/Microsoft.AspNet.Mvc.Razor/HelperResult.cs b/src/Microsoft.AspNet.Mvc.Razor/HelperResult.cs index 8da4899011..734118e0c9 100644 --- a/src/Microsoft.AspNet.Mvc.Razor/HelperResult.cs +++ b/src/Microsoft.AspNet.Mvc.Razor/HelperResult.cs @@ -3,9 +3,9 @@ using System; using System.IO; +using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNet.Html.Abstractions; -using Microsoft.Extensions.WebEncoders; namespace Microsoft.AspNet.Mvc.Razor { @@ -20,8 +20,8 @@ namespace Microsoft.AspNet.Mvc.Razor /// Creates a new instance of . /// /// The asynchronous delegate to invoke when - /// is called. - /// Calls to result in a blocking invocation of + /// is called. + /// Calls to result in a blocking invocation of /// . public HelperResult(Func asyncAction) { @@ -34,7 +34,7 @@ namespace Microsoft.AspNet.Mvc.Razor } /// - /// Gets the asynchronous delegate to invoke when is called. + /// Gets the asynchronous delegate to invoke when is called. /// public Func WriteAction { @@ -45,8 +45,8 @@ namespace Microsoft.AspNet.Mvc.Razor /// Method invoked to produce content from the . /// /// The instance to write to. - /// The to encode the content. - public virtual void WriteTo(TextWriter writer, IHtmlEncoder encoder) + /// The to encode the content. + public virtual void WriteTo(TextWriter writer, HtmlEncoder encoder) { if (writer == null) { diff --git a/src/Microsoft.AspNet.Mvc.Razor/RazorPage.cs b/src/Microsoft.AspNet.Mvc.Razor/RazorPage.cs index 032dfc3b37..266f072555 100644 --- a/src/Microsoft.AspNet.Mvc.Razor/RazorPage.cs +++ b/src/Microsoft.AspNet.Mvc.Razor/RazorPage.cs @@ -8,6 +8,7 @@ using System.Globalization; using System.IO; using System.Linq; using System.Security.Claims; +using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNet.Antiforgery; using Microsoft.AspNet.Html.Abstractions; @@ -20,7 +21,6 @@ using Microsoft.AspNet.PageExecutionInstrumentation; using Microsoft.AspNet.Razor.Runtime.TagHelpers; using Microsoft.AspNet.Razor.TagHelpers; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.WebEncoders; namespace Microsoft.AspNet.Mvc.Razor { @@ -76,10 +76,10 @@ namespace Microsoft.AspNet.Mvc.Razor public bool IsPartial { get; set; } /// - /// Gets the to be used for encoding HTML. + /// Gets the to be used for encoding HTML. /// [RazorInject] - public IHtmlEncoder HtmlEncoder { get; set; } + public HtmlEncoder HtmlEncoder { get; set; } /// public IPageExecutionContext PageExecutionContext { get; set; } @@ -423,7 +423,7 @@ namespace Microsoft.AspNet.Mvc.Razor /// The to write. /// /// s of type are written using - /// . + /// . /// For all other types, the encoded result of is written to the /// . /// @@ -441,7 +441,7 @@ namespace Microsoft.AspNet.Mvc.Razor /// Writes the specified with HTML encoding to given . /// /// The instance to write to. - /// The to use when encoding . + /// The to use when encoding . /// The to write. /// /// If true escapes double quotes in a of type . @@ -449,13 +449,13 @@ namespace Microsoft.AspNet.Mvc.Razor /// /// /// s of type are written using - /// . + /// . /// For all other types, the encoded result of is written to the /// . /// public static void WriteTo( TextWriter writer, - IHtmlEncoder encoder, + HtmlEncoder encoder, object value, bool escapeQuotes) { @@ -532,11 +532,11 @@ namespace Microsoft.AspNet.Mvc.Razor WriteTo(writer, HtmlEncoder, value); } - private static void WriteTo(TextWriter writer, IHtmlEncoder encoder, string value) + private static void WriteTo(TextWriter writer, HtmlEncoder encoder, string value) { if (!string.IsNullOrEmpty(value)) { - encoder.HtmlEncode(value, writer); + encoder.Encode(writer, value); } } diff --git a/src/Microsoft.AspNet.Mvc.Razor/RazorTextWriter.cs b/src/Microsoft.AspNet.Mvc.Razor/RazorTextWriter.cs index d7eb2c40b1..388ad77770 100644 --- a/src/Microsoft.AspNet.Mvc.Razor/RazorTextWriter.cs +++ b/src/Microsoft.AspNet.Mvc.Razor/RazorTextWriter.cs @@ -4,10 +4,10 @@ using System; using System.IO; using System.Text; +using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNet.Html.Abstractions; using Microsoft.AspNet.Mvc.ViewFeatures; -using Microsoft.Extensions.WebEncoders; namespace Microsoft.AspNet.Mvc.Razor { @@ -30,7 +30,7 @@ namespace Microsoft.AspNet.Mvc.Razor /// is no longer buffering. /// The character in which the output is written. /// The HTML encoder. - public RazorTextWriter(TextWriter unbufferedWriter, Encoding encoding, IHtmlEncoder encoder) + public RazorTextWriter(TextWriter unbufferedWriter, Encoding encoding, HtmlEncoder encoder) { UnbufferedWriter = unbufferedWriter; HtmlEncoder = encoder; @@ -55,7 +55,7 @@ namespace Microsoft.AspNet.Mvc.Razor private TextWriter TargetWriter { get; set; } - private IHtmlEncoder HtmlEncoder { get; } + private HtmlEncoder HtmlEncoder { get; } /// public override void Write(char value) diff --git a/src/Microsoft.AspNet.Mvc.Razor/RazorView.cs b/src/Microsoft.AspNet.Mvc.Razor/RazorView.cs index ea182cd21f..5c5620203f 100644 --- a/src/Microsoft.AspNet.Mvc.Razor/RazorView.cs +++ b/src/Microsoft.AspNet.Mvc.Razor/RazorView.cs @@ -5,25 +5,25 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNet.Http.Features; using Microsoft.AspNet.Mvc.Rendering; using Microsoft.AspNet.Mvc.ViewEngines; using Microsoft.AspNet.PageExecutionInstrumentation; -using Microsoft.Extensions.WebEncoders; namespace Microsoft.AspNet.Mvc.Razor { /// /// Default implementation for that executes one or more - /// as parts of its exeuction. + /// as parts of its execution. /// public class RazorView : IView { private readonly IRazorViewEngine _viewEngine; private readonly IRazorPageActivator _pageActivator; private readonly IViewStartProvider _viewStartProvider; - private readonly IHtmlEncoder _htmlEncoder; + private readonly HtmlEncoder _htmlEncoder; private IPageExecutionListenerFeature _pageExecutionFeature; /// @@ -41,7 +41,7 @@ namespace Microsoft.AspNet.Mvc.Razor IRazorPageActivator pageActivator, IViewStartProvider viewStartProvider, IRazorPage razorPage, - IHtmlEncoder htmlEncoder, + HtmlEncoder htmlEncoder, bool isPartial) { _viewEngine = viewEngine; diff --git a/src/Microsoft.AspNet.Mvc.Razor/RazorViewFactory.cs b/src/Microsoft.AspNet.Mvc.Razor/RazorViewFactory.cs index 7de4f7e598..661926a481 100644 --- a/src/Microsoft.AspNet.Mvc.Razor/RazorViewFactory.cs +++ b/src/Microsoft.AspNet.Mvc.Razor/RazorViewFactory.cs @@ -2,8 +2,8 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Text.Encodings.Web; using Microsoft.AspNet.Mvc.ViewEngines; -using Microsoft.Extensions.WebEncoders; namespace Microsoft.AspNet.Mvc.Razor { @@ -13,7 +13,7 @@ namespace Microsoft.AspNet.Mvc.Razor /// public class RazorViewFactory : IRazorViewFactory { - private readonly IHtmlEncoder _htmlEncoder; + private readonly HtmlEncoder _htmlEncoder; private readonly IRazorPageActivator _pageActivator; private readonly IViewStartProvider _viewStartProvider; @@ -26,7 +26,7 @@ namespace Microsoft.AspNet.Mvc.Razor public RazorViewFactory( IRazorPageActivator pageActivator, IViewStartProvider viewStartProvider, - IHtmlEncoder htmlEncoder) + HtmlEncoder htmlEncoder) { _pageActivator = pageActivator; _viewStartProvider = viewStartProvider; diff --git a/src/Microsoft.AspNet.Mvc.Razor/TagHelpers/UrlResolutionTagHelper.cs b/src/Microsoft.AspNet.Mvc.Razor/TagHelpers/UrlResolutionTagHelper.cs index 3e2f679394..689ff37483 100644 --- a/src/Microsoft.AspNet.Mvc.Razor/TagHelpers/UrlResolutionTagHelper.cs +++ b/src/Microsoft.AspNet.Mvc.Razor/TagHelpers/UrlResolutionTagHelper.cs @@ -5,9 +5,9 @@ using System; using System.Collections.Generic; using System.ComponentModel; using System.Reflection; +using System.Text.Encodings.Web; using Microsoft.AspNet.Mvc.Rendering; using Microsoft.AspNet.Razor.TagHelpers; -using Microsoft.Extensions.WebEncoders; namespace Microsoft.AspNet.Mvc.Razor.TagHelpers { @@ -84,8 +84,8 @@ namespace Microsoft.AspNet.Mvc.Razor.TagHelpers /// Creates a new . /// /// The . - /// The . - public UrlResolutionTagHelper(IUrlHelper urlHelper, IHtmlEncoder htmlEncoder) + /// The . + public UrlResolutionTagHelper(IUrlHelper urlHelper, HtmlEncoder htmlEncoder) { UrlHelper = urlHelper; HtmlEncoder = htmlEncoder; @@ -102,7 +102,7 @@ namespace Microsoft.AspNet.Mvc.Razor.TagHelpers protected IUrlHelper UrlHelper { get; } - protected IHtmlEncoder HtmlEncoder { get; } + protected HtmlEncoder HtmlEncoder { get; } /// public override void Process(TagHelperContext context, TagHelperOutput output) @@ -221,7 +221,7 @@ namespace Microsoft.AspNet.Mvc.Razor.TagHelpers } var applicationPath = appRelativeUrl.Substring(0, appRelativeUrl.Length - postTildeSlashUrlValue.Length); - var encodedApplicationPath = HtmlEncoder.HtmlEncode(applicationPath); + var encodedApplicationPath = HtmlEncoder.Encode(applicationPath); resolvedUrl = string.Concat(encodedApplicationPath, postTildeSlashUrlValue); } diff --git a/src/Microsoft.AspNet.Mvc.TagHelpers/ImageTagHelper.cs b/src/Microsoft.AspNet.Mvc.TagHelpers/ImageTagHelper.cs index ced5cf516e..ae411f9041 100644 --- a/src/Microsoft.AspNet.Mvc.TagHelpers/ImageTagHelper.cs +++ b/src/Microsoft.AspNet.Mvc.TagHelpers/ImageTagHelper.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Text.Encodings.Web; using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Mvc.Razor.TagHelpers; using Microsoft.AspNet.Mvc.Rendering; @@ -9,7 +10,6 @@ using Microsoft.AspNet.Mvc.TagHelpers.Internal; using Microsoft.AspNet.Mvc.ViewFeatures; using Microsoft.AspNet.Razor.TagHelpers; using Microsoft.Extensions.Caching.Memory; -using Microsoft.Extensions.WebEncoders; namespace Microsoft.AspNet.Mvc.TagHelpers { @@ -41,7 +41,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers public ImageTagHelper( IHostingEnvironment hostingEnvironment, IMemoryCache cache, - IHtmlEncoder htmlEncoder, + HtmlEncoder htmlEncoder, IUrlHelper urlHelper) : base(urlHelper, htmlEncoder) { diff --git a/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/JavaScriptStringArrayEncoder.cs b/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/JavaScriptStringArrayEncoder.cs index 06cc5ec103..fcc3a0940c 100644 --- a/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/JavaScriptStringArrayEncoder.cs +++ b/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/JavaScriptStringArrayEncoder.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.IO; -using Microsoft.Extensions.WebEncoders; +using System.Text.Encodings.Web; namespace Microsoft.AspNet.Mvc.TagHelpers.Internal { @@ -15,7 +15,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers.Internal /// /// Encodes a .NET string array for safe use as a JavaScript array literal, including inline in an HTML file. /// - public static string Encode(IJavaScriptStringEncoder encoder, IEnumerable values) + public static string Encode(JavaScriptEncoder encoder, IEnumerable values) { var writer = new StringWriter(); @@ -30,7 +30,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers.Internal writer.Write(','); } writer.Write('"'); - encoder.JavaScriptStringEncode(value, writer); + encoder.Encode(writer, value); writer.Write('"'); firstAdded = true; } diff --git a/src/Microsoft.AspNet.Mvc.TagHelpers/LinkTagHelper.cs b/src/Microsoft.AspNet.Mvc.TagHelpers/LinkTagHelper.cs index c1a331fa33..4768c34560 100644 --- a/src/Microsoft.AspNet.Mvc.TagHelpers/LinkTagHelper.cs +++ b/src/Microsoft.AspNet.Mvc.TagHelpers/LinkTagHelper.cs @@ -5,6 +5,7 @@ using System; using System.Diagnostics; using System.Globalization; using System.Linq; +using System.Text.Encodings.Web; using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Mvc.Razor.TagHelpers; using Microsoft.AspNet.Mvc.Rendering; @@ -13,7 +14,6 @@ using Microsoft.AspNet.Mvc.ViewFeatures; using Microsoft.AspNet.Razor.TagHelpers; using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.WebEncoders; namespace Microsoft.AspNet.Mvc.TagHelpers { @@ -91,15 +91,15 @@ namespace Microsoft.AspNet.Mvc.TagHelpers /// The . /// The . /// The . - /// The . - /// The . + /// The . + /// The . /// The . public LinkTagHelper( ILogger logger, IHostingEnvironment hostingEnvironment, IMemoryCache cache, - IHtmlEncoder htmlEncoder, - IJavaScriptStringEncoder javaScriptEncoder, + HtmlEncoder htmlEncoder, + JavaScriptEncoder javaScriptEncoder, IUrlHelper urlHelper) : base(urlHelper, htmlEncoder) { @@ -208,7 +208,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers protected IMemoryCache Cache { get; } - protected IJavaScriptStringEncoder JavaScriptEncoder { get; } + protected JavaScriptEncoder JavaScriptEncoder { get; } // Internal for ease of use when testing. protected internal GlobbingUrlBuilder GlobbingUrlBuilder { get; set; } @@ -351,8 +351,8 @@ namespace Microsoft.AspNet.Mvc.TagHelpers string.Format( CultureInfo.InvariantCulture, JavaScriptResources.GetEmbeddedJavaScript(FallbackJavaScriptResourceName), - JavaScriptEncoder.JavaScriptStringEncode(FallbackTestProperty), - JavaScriptEncoder.JavaScriptStringEncode(FallbackTestValue), + JavaScriptEncoder.Encode(FallbackTestProperty), + JavaScriptEncoder.Encode(FallbackTestValue), JavaScriptStringArrayEncoder.Encode(JavaScriptEncoder, fallbackHrefs))) .AppendHtml(""); } diff --git a/src/Microsoft.AspNet.Mvc.TagHelpers/ScriptTagHelper.cs b/src/Microsoft.AspNet.Mvc.TagHelpers/ScriptTagHelper.cs index e72fb84277..50ffeb72ec 100644 --- a/src/Microsoft.AspNet.Mvc.TagHelpers/ScriptTagHelper.cs +++ b/src/Microsoft.AspNet.Mvc.TagHelpers/ScriptTagHelper.cs @@ -4,6 +4,7 @@ using System; using System.Diagnostics; using System.Linq; +using System.Text.Encodings.Web; using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Mvc.Razor.TagHelpers; using Microsoft.AspNet.Mvc.Rendering; @@ -12,7 +13,6 @@ using Microsoft.AspNet.Mvc.ViewFeatures; using Microsoft.AspNet.Razor.TagHelpers; using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.WebEncoders; namespace Microsoft.AspNet.Mvc.TagHelpers { @@ -77,15 +77,15 @@ namespace Microsoft.AspNet.Mvc.TagHelpers /// The . /// The . /// The . - /// The . - /// The . + /// The . + /// The . /// The . public ScriptTagHelper( ILogger logger, IHostingEnvironment hostingEnvironment, IMemoryCache cache, - IHtmlEncoder htmlEncoder, - IJavaScriptStringEncoder javaScriptEncoder, + HtmlEncoder htmlEncoder, + JavaScriptEncoder javaScriptEncoder, IUrlHelper urlHelper) : base(urlHelper, htmlEncoder) { @@ -176,7 +176,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers protected IMemoryCache Cache { get; } - protected IJavaScriptStringEncoder JavaScriptEncoder { get; } + protected JavaScriptEncoder JavaScriptEncoder { get; } // Internal for ease of use when testing. protected internal GlobbingUrlBuilder GlobbingUrlBuilder { get; set; } @@ -316,9 +316,9 @@ namespace Microsoft.AspNet.Mvc.TagHelpers { if (!attribute.Name.Equals(SrcAttributeName, StringComparison.OrdinalIgnoreCase)) { - var encodedKey = JavaScriptEncoder.JavaScriptStringEncode(attribute.Name); + var encodedKey = JavaScriptEncoder.Encode(attribute.Name); var attributeValue = attribute.Value.ToString(); - var encodedValue = JavaScriptEncoder.JavaScriptStringEncode(attributeValue); + var encodedValue = JavaScriptEncoder.Encode(attributeValue); AppendAttribute(builder, encodedKey, encodedValue, escapeQuotes: true); } @@ -332,7 +332,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers } // attribute.Key ("src") does not need to be JavaScript-encoded. - var encodedValue = JavaScriptEncoder.JavaScriptStringEncode(attributeValue); + var encodedValue = JavaScriptEncoder.Encode(attributeValue); AppendAttribute(builder, attribute.Name, encodedValue, escapeQuotes: true); } diff --git a/src/Microsoft.AspNet.Mvc.TagHelpers/TagHelperContentExtensions.cs b/src/Microsoft.AspNet.Mvc.TagHelpers/TagHelperContentExtensions.cs index 84d1c8d778..8604fb30e8 100644 --- a/src/Microsoft.AspNet.Mvc.TagHelpers/TagHelperContentExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.TagHelpers/TagHelperContentExtensions.cs @@ -3,9 +3,9 @@ using System; using System.Text; +using System.Text.Encodings.Web; using Microsoft.AspNet.Mvc.Razor; using Microsoft.AspNet.Razor.TagHelpers; -using Microsoft.Extensions.WebEncoders; namespace Microsoft.AspNet.Mvc.TagHelpers { @@ -18,19 +18,19 @@ namespace Microsoft.AspNet.Mvc.TagHelpers /// Writes the specified with HTML encoding to given . /// /// The to write to. - /// The to use when encoding . + /// The to use when encoding . /// The character encoding in which the is written. /// The to write. /// after the write operation has completed. /// /// s of type are written using - /// . + /// . /// For all other types, the encoded result of /// is written to the . /// public static TagHelperContent Append( this TagHelperContent content, - IHtmlEncoder encoder, + HtmlEncoder encoder, Encoding encoding, object value) { diff --git a/src/Microsoft.AspNet.Mvc.ViewFeatures/Rendering/HtmlString.cs b/src/Microsoft.AspNet.Mvc.ViewFeatures/Rendering/HtmlString.cs index 946080adae..e16d9a671f 100644 --- a/src/Microsoft.AspNet.Mvc.ViewFeatures/Rendering/HtmlString.cs +++ b/src/Microsoft.AspNet.Mvc.ViewFeatures/Rendering/HtmlString.cs @@ -3,8 +3,8 @@ using System; using System.IO; +using System.Text.Encodings.Web; using Microsoft.AspNet.Html.Abstractions; -using Microsoft.Extensions.WebEncoders; namespace Microsoft.AspNet.Mvc.Rendering { @@ -35,7 +35,7 @@ namespace Microsoft.AspNet.Mvc.Rendering } /// - public void WriteTo(TextWriter writer, IHtmlEncoder encoder) + public void WriteTo(TextWriter writer, HtmlEncoder encoder) { if (writer == null) { diff --git a/src/Microsoft.AspNet.Mvc.ViewFeatures/Rendering/IHtmlHelper.cs b/src/Microsoft.AspNet.Mvc.ViewFeatures/Rendering/IHtmlHelper.cs index ccd46a3022..cfbe0a670d 100644 --- a/src/Microsoft.AspNet.Mvc.ViewFeatures/Rendering/IHtmlHelper.cs +++ b/src/Microsoft.AspNet.Mvc.ViewFeatures/Rendering/IHtmlHelper.cs @@ -3,12 +3,12 @@ using System; using System.Collections.Generic; +using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNet.Html.Abstractions; using Microsoft.AspNet.Mvc.ModelBinding; using Microsoft.AspNet.Mvc.ModelBinding.Validation; using Microsoft.AspNet.Mvc.ViewFeatures; -using Microsoft.Extensions.WebEncoders; namespace Microsoft.AspNet.Mvc.Rendering { @@ -55,14 +55,14 @@ namespace Microsoft.AspNet.Mvc.Rendering ITempDataDictionary TempData { get; } /// - /// Gets the to be used for encoding a URL. + /// Gets the to be used for encoding a URL. /// - IUrlEncoder UrlEncoder { get; } + UrlEncoder UrlEncoder { get; } /// - /// Gets the to be used for encoding JavaScript. + /// Gets the to be used for encoding JavaScript. /// - IJavaScriptStringEncoder JavaScriptStringEncoder { get; } + JavaScriptEncoder JavaScriptEncoder { get; } /// /// Returns an anchor (<a>) element that contains a URL path to the specified action. diff --git a/src/Microsoft.AspNet.Mvc.ViewFeatures/Rendering/MvcForm.cs b/src/Microsoft.AspNet.Mvc.ViewFeatures/Rendering/MvcForm.cs index 1d45c28ea0..aed7cac014 100644 --- a/src/Microsoft.AspNet.Mvc.ViewFeatures/Rendering/MvcForm.cs +++ b/src/Microsoft.AspNet.Mvc.ViewFeatures/Rendering/MvcForm.cs @@ -2,8 +2,8 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Text.Encodings.Web; using Microsoft.AspNet.Mvc.ViewFeatures; -using Microsoft.Extensions.WebEncoders; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.AspNet.Mvc.Rendering @@ -61,10 +61,10 @@ namespace Microsoft.AspNet.Mvc.Rendering var writer = _viewContext.Writer; var htmlWriter = writer as HtmlTextWriter; - IHtmlEncoder htmlEncoder = null; + HtmlEncoder htmlEncoder = null; if (htmlWriter == null) { - htmlEncoder = _viewContext.HttpContext.RequestServices.GetRequiredService(); + htmlEncoder = _viewContext.HttpContext.RequestServices.GetRequiredService(); } foreach (var content in formContext.EndOfFormContent) diff --git a/src/Microsoft.AspNet.Mvc.ViewFeatures/Rendering/TagBuilder.cs b/src/Microsoft.AspNet.Mvc.ViewFeatures/Rendering/TagBuilder.cs index bc02641e78..1acfeb3b91 100644 --- a/src/Microsoft.AspNet.Mvc.ViewFeatures/Rendering/TagBuilder.cs +++ b/src/Microsoft.AspNet.Mvc.ViewFeatures/Rendering/TagBuilder.cs @@ -7,10 +7,10 @@ using System.Diagnostics; using System.Globalization; using System.IO; using System.Text; +using System.Text.Encodings.Web; using Microsoft.AspNet.Html.Abstractions; using Microsoft.AspNet.Mvc.ViewFeatures; using Microsoft.Extensions.Internal; -using Microsoft.Extensions.WebEncoders; namespace Microsoft.AspNet.Mvc.Rendering { @@ -189,7 +189,7 @@ namespace Microsoft.AspNet.Mvc.Rendering } } - private void AppendAttributes(TextWriter writer, IHtmlEncoder encoder) + private void AppendAttributes(TextWriter writer, HtmlEncoder encoder) { // Perf: Avoid allocating enumerator for `_attributes` if possible if (_attributes != null && _attributes.Count > 0) @@ -206,7 +206,7 @@ namespace Microsoft.AspNet.Mvc.Rendering writer.Write(" "); writer.Write(key); writer.Write("=\""); - encoder.HtmlEncode(attribute.Value, writer); + encoder.Encode(writer, attribute.Value); writer.Write("\""); } } @@ -250,7 +250,7 @@ namespace Microsoft.AspNet.Mvc.Rendering } /// - public void WriteTo(TextWriter writer, IHtmlEncoder encoder) + public void WriteTo(TextWriter writer, HtmlEncoder encoder) { switch (TagRenderMode) { diff --git a/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/DefaultHtmlGenerator.cs b/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/DefaultHtmlGenerator.cs index 72dfd6bcf7..58c941e785 100644 --- a/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/DefaultHtmlGenerator.cs +++ b/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/DefaultHtmlGenerator.cs @@ -8,6 +8,7 @@ using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; +using System.Text.Encodings.Web; using Microsoft.AspNet.Antiforgery; using Microsoft.AspNet.Html.Abstractions; using Microsoft.AspNet.Mvc.ModelBinding; @@ -16,7 +17,6 @@ using Microsoft.AspNet.Mvc.Rendering; using Microsoft.AspNet.Mvc.ViewFeatures.Internal; using Microsoft.Extensions.Internal; using Microsoft.Extensions.OptionsModel; -using Microsoft.Extensions.WebEncoders; namespace Microsoft.AspNet.Mvc.ViewFeatures { @@ -30,7 +30,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures private readonly IClientModelValidatorProvider _clientModelValidatorProvider; private readonly IModelMetadataProvider _metadataProvider; private readonly IUrlHelper _urlHelper; - private readonly IHtmlEncoder _htmlEncoder; + private readonly HtmlEncoder _htmlEncoder; /// /// Initializes a new instance of the class. @@ -40,13 +40,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures /// The accessor for . /// The . /// The . - /// The . + /// The . public DefaultHtmlGenerator( IAntiforgery antiforgery, IOptions optionsAccessor, IModelMetadataProvider metadataProvider, IUrlHelper urlHelper, - IHtmlEncoder htmlEncoder) + HtmlEncoder htmlEncoder) { if (antiforgery == null) { @@ -90,13 +90,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures /// public string Encode(string value) { - return !string.IsNullOrEmpty(value) ? _htmlEncoder.HtmlEncode(value) : string.Empty; + return !string.IsNullOrEmpty(value) ? _htmlEncoder.Encode(value) : string.Empty; } /// public string Encode(object value) { - return (value != null) ? _htmlEncoder.HtmlEncode(value.ToString()) : string.Empty; + return (value != null) ? _htmlEncoder.Encode(value.ToString()) : string.Empty; } /// diff --git a/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/HtmlHelper.cs b/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/HtmlHelper.cs index fbd327e4d9..0dc821dbbd 100644 --- a/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/HtmlHelper.cs +++ b/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/HtmlHelper.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; +using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNet.Html.Abstractions; using Microsoft.AspNet.Mvc.ModelBinding; @@ -14,7 +15,6 @@ using Microsoft.AspNet.Mvc.Rendering; using Microsoft.AspNet.Mvc.ViewEngines; using Microsoft.AspNet.Mvc.ViewFeatures.Internal; using Microsoft.Extensions.Internal; -using Microsoft.Extensions.WebEncoders; namespace Microsoft.AspNet.Mvc.ViewFeatures { @@ -32,7 +32,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures private readonly IHtmlGenerator _htmlGenerator; private readonly ICompositeViewEngine _viewEngine; - private readonly IHtmlEncoder _htmlEncoder; + private readonly HtmlEncoder _htmlEncoder; private ViewContext _viewContext; @@ -43,9 +43,9 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures IHtmlGenerator htmlGenerator, ICompositeViewEngine viewEngine, IModelMetadataProvider metadataProvider, - IHtmlEncoder htmlEncoder, - IUrlEncoder urlEncoder, - IJavaScriptStringEncoder javaScriptStringEncoder) + HtmlEncoder htmlEncoder, + UrlEncoder urlEncoder, + JavaScriptEncoder javaScriptEncoder) { if (htmlGenerator == null) { @@ -72,9 +72,9 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures throw new ArgumentNullException(nameof(urlEncoder)); } - if (javaScriptStringEncoder == null) + if (javaScriptEncoder == null) { - throw new ArgumentNullException(nameof(javaScriptStringEncoder)); + throw new ArgumentNullException(nameof(javaScriptEncoder)); } _viewEngine = viewEngine; @@ -82,7 +82,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures _htmlEncoder = htmlEncoder; MetadataProvider = metadataProvider; UrlEncoder = urlEncoder; - JavaScriptStringEncoder = javaScriptStringEncoder; + JavaScriptEncoder = javaScriptEncoder; } /// @@ -153,10 +153,10 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures } /// - public IUrlEncoder UrlEncoder { get; } + public UrlEncoder UrlEncoder { get; } /// - public IJavaScriptStringEncoder JavaScriptStringEncoder { get; } + public JavaScriptEncoder JavaScriptEncoder { get; } /// public IModelMetadataProvider MetadataProvider { get; } diff --git a/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/HtmlHelperOfT.cs b/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/HtmlHelperOfT.cs index 7960ec50f2..75ae32118e 100644 --- a/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/HtmlHelperOfT.cs +++ b/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/HtmlHelperOfT.cs @@ -4,11 +4,11 @@ using System; using System.Collections.Generic; using System.Linq.Expressions; +using System.Text.Encodings.Web; using Microsoft.AspNet.Html.Abstractions; using Microsoft.AspNet.Mvc.ModelBinding; using Microsoft.AspNet.Mvc.Rendering; using Microsoft.AspNet.Mvc.ViewEngines; -using Microsoft.Extensions.WebEncoders; namespace Microsoft.AspNet.Mvc.ViewFeatures { @@ -21,10 +21,10 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures IHtmlGenerator htmlGenerator, ICompositeViewEngine viewEngine, IModelMetadataProvider metadataProvider, - IHtmlEncoder htmlEncoder, - IUrlEncoder urlEncoder, - IJavaScriptStringEncoder javaScriptStringEncoder) - : base(htmlGenerator, viewEngine, metadataProvider, htmlEncoder, urlEncoder, javaScriptStringEncoder) + HtmlEncoder htmlEncoder, + UrlEncoder urlEncoder, + JavaScriptEncoder javaScriptEncoder) + : base(htmlGenerator, viewEngine, metadataProvider, htmlEncoder, urlEncoder, javaScriptEncoder) { if (htmlGenerator == null) { @@ -46,9 +46,9 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures { throw new ArgumentNullException(nameof(urlEncoder)); } - if (javaScriptStringEncoder == null) + if (javaScriptEncoder == null) { - throw new ArgumentNullException(nameof(javaScriptStringEncoder)); + throw new ArgumentNullException(nameof(javaScriptEncoder)); } } diff --git a/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/StringCollectionTextWriter.cs b/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/StringCollectionTextWriter.cs index d3a369c315..2190eb44a3 100644 --- a/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/StringCollectionTextWriter.cs +++ b/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/StringCollectionTextWriter.cs @@ -6,9 +6,9 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Text; +using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNet.Html.Abstractions; -using Microsoft.Extensions.WebEncoders; namespace Microsoft.AspNet.Mvc.ViewFeatures { @@ -180,8 +180,8 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures /// are copied. It is just written to the otherwise. /// /// The to which the content must be copied/written. - /// The to encode the copied/written content. - public void CopyTo(TextWriter writer, IHtmlEncoder encoder) + /// The to encode the copied/written content. + public void CopyTo(TextWriter writer, HtmlEncoder encoder) { var targetStringCollectionWriter = writer as StringCollectionTextWriter; if (targetStringCollectionWriter != null) @@ -199,8 +199,8 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures /// are copied. It is just written to the otherwise. /// /// The to which the content must be copied/written. - /// The to encode the copied/written content. - public Task CopyToAsync(TextWriter writer, IHtmlEncoder encoder) + /// The to encode the copied/written content. + public Task CopyToAsync(TextWriter writer, HtmlEncoder encoder) { CopyTo(writer, encoder); return _completedTask; @@ -226,7 +226,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures _entries.Add(content); } - public void WriteTo(TextWriter writer, IHtmlEncoder encoder) + public void WriteTo(TextWriter writer, HtmlEncoder encoder) { foreach (var item in _entries) { diff --git a/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/StringHtmlContent.cs b/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/StringHtmlContent.cs index 9af415cdb4..bdbc8b8ef5 100644 --- a/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/StringHtmlContent.cs +++ b/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/StringHtmlContent.cs @@ -4,8 +4,8 @@ using System; using System.Diagnostics; using System.IO; +using System.Text.Encodings.Web; using Microsoft.AspNet.Html.Abstractions; -using Microsoft.Extensions.WebEncoders; namespace Microsoft.AspNet.Mvc.ViewFeatures { @@ -27,7 +27,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures } /// - public void WriteTo(TextWriter writer, IHtmlEncoder encoder) + public void WriteTo(TextWriter writer, HtmlEncoder encoder) { if (writer == null) { @@ -39,7 +39,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures throw new ArgumentNullException(nameof(encoder)); } - encoder.HtmlEncode(_input, writer); + encoder.Encode(writer, _input); } private string DebuggerToString() diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/MvcEncodedTestFixtureOfT.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/MvcEncodedTestFixtureOfT.cs index 2d3a0cca8a..afb356bda3 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/MvcEncodedTestFixtureOfT.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/MvcEncodedTestFixtureOfT.cs @@ -1,8 +1,8 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System.Text.Encodings.Web; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.WebEncoders; using Microsoft.Extensions.WebEncoders.Testing; namespace Microsoft.AspNet.Mvc.FunctionalTests @@ -12,9 +12,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests { protected override void AddAdditionalServices(IServiceCollection services) { - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/compiler/resources/HtmlGenerationWebSite.HtmlGeneration_Home.Link.Encoded.html b/test/Microsoft.AspNet.Mvc.FunctionalTests/compiler/resources/HtmlGenerationWebSite.HtmlGeneration_Home.Link.Encoded.html index 96eb7ef151..c8910356c0 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/compiler/resources/HtmlGenerationWebSite.HtmlGeneration_Home.Link.Encoded.html +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/compiler/resources/HtmlGenerationWebSite.HtmlGeneration_Home.Link.Encoded.html @@ -39,63 +39,63 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -120,7 +120,7 @@ - + diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/compiler/resources/HtmlGenerationWebSite.HtmlGeneration_Home.Script.Encoded.html b/test/Microsoft.AspNet.Mvc.FunctionalTests/compiler/resources/HtmlGenerationWebSite.HtmlGeneration_Home.Script.Encoded.html index 89e6020c72..433539425e 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/compiler/resources/HtmlGenerationWebSite.HtmlGeneration_Home.Script.Encoded.html +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/compiler/resources/HtmlGenerationWebSite.HtmlGeneration_Home.Script.Encoded.html @@ -13,27 +13,27 @@ - + - + - + - + - + - + - + - + - + ", output.PostElement.GetContent()); } @@ -876,8 +876,8 @@ namespace Microsoft.AspNet.Mvc.TagHelpers logger.Object, MakeHostingEnvironment(), MakeCache(), - new CommonTestEncoder(), - new CommonTestEncoder(), + new HtmlTestEncoder(), + new JavaScriptTestEncoder(), MakeUrlHelper()) { GlobbingUrlBuilder = globbingUrlBuilder.Object, diff --git a/test/Microsoft.AspNet.Mvc.TagHelpers.Test/TestableHtmlGenerator.cs b/test/Microsoft.AspNet.Mvc.TagHelpers.Test/TestableHtmlGenerator.cs index 2264e3ed7f..edb469937e 100644 --- a/test/Microsoft.AspNet.Mvc.TagHelpers.Test/TestableHtmlGenerator.cs +++ b/test/Microsoft.AspNet.Mvc.TagHelpers.Test/TestableHtmlGenerator.cs @@ -43,7 +43,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers IOptions options, IUrlHelper urlHelper, IDictionary validationAttributes) - : base(Mock.Of(), options, metadataProvider, urlHelper, new CommonTestEncoder()) + : base(Mock.Of(), options, metadataProvider, urlHelper, new HtmlTestEncoder()) { _validationAttributes = validationAttributes; } diff --git a/test/Microsoft.AspNet.Mvc.TestCommon/HtmlContentUtilities.cs b/test/Microsoft.AspNet.Mvc.TestCommon/HtmlContentUtilities.cs index e2b73cf1d4..b7c9363520 100644 --- a/test/Microsoft.AspNet.Mvc.TestCommon/HtmlContentUtilities.cs +++ b/test/Microsoft.AspNet.Mvc.TestCommon/HtmlContentUtilities.cs @@ -2,19 +2,19 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.IO; +using System.Text.Encodings.Web; using Microsoft.AspNet.Html.Abstractions; -using Microsoft.Extensions.WebEncoders; using Microsoft.Extensions.WebEncoders.Testing; namespace Microsoft.AspNet.Mvc.TestCommon { public class HtmlContentUtilities { - public static string HtmlContentToString(IHtmlContent content, IHtmlEncoder encoder = null) + public static string HtmlContentToString(IHtmlContent content, HtmlEncoder encoder = null) { if (encoder == null) { - encoder = new CommonTestEncoder(); + encoder = new HtmlTestEncoder(); } using (var writer = new StringWriter()) diff --git a/test/Microsoft.AspNet.Mvc.TestCommon/TestHtmlEncoder.cs b/test/Microsoft.AspNet.Mvc.TestCommon/TestHtmlEncoder.cs deleted file mode 100644 index ac0fce1e95..0000000000 --- a/test/Microsoft.AspNet.Mvc.TestCommon/TestHtmlEncoder.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.IO; - -namespace Microsoft.Extensions.WebEncoders -{ - internal class TestHtmlEncoder : IHtmlEncoder - { - public string HtmlEncode(string value) - { - return $"HtmlEncode[[{ value }]]"; - } - - public void HtmlEncode(string value, int startIndex, int charCount, TextWriter output) - { - output.Write($"HtmlEncode[[{ value.Substring(startIndex, charCount) }]]"); - } - - public void HtmlEncode(char[] value, int startIndex, int charCount, TextWriter output) - { - output.Write("HtmlEncode[["); - output.Write(value, startIndex, charCount); - output.Write("]]"); - } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.TestCommon/TestJavaScriptEncoder.cs b/test/Microsoft.AspNet.Mvc.TestCommon/TestJavaScriptEncoder.cs deleted file mode 100644 index a849e631b2..0000000000 --- a/test/Microsoft.AspNet.Mvc.TestCommon/TestJavaScriptEncoder.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.IO; - -namespace Microsoft.Extensions.WebEncoders -{ - internal class TestJavaScriptEncoder : IJavaScriptStringEncoder - { - public string JavaScriptStringEncode(string value) - { - return $"JavaScriptEncode[[{ value }]]"; - } - - public void JavaScriptStringEncode(string value, int startIndex, int charCount, TextWriter output) - { - output.Write($"JavaScriptEncode[[{ value.Substring(startIndex, charCount) }]]"); - } - - public void JavaScriptStringEncode(char[] value, int startIndex, int charCount, TextWriter output) - { - output.Write("JavaScriptEncode[["); - output.Write(value, startIndex, charCount); - output.Write("]]"); - } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.TestCommon/TestUrlEncoder.cs b/test/Microsoft.AspNet.Mvc.TestCommon/TestUrlEncoder.cs deleted file mode 100644 index f24cae3b72..0000000000 --- a/test/Microsoft.AspNet.Mvc.TestCommon/TestUrlEncoder.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.IO; - -namespace Microsoft.Extensions.WebEncoders -{ - internal class TestUrlEncoder : IUrlEncoder - { - public string UrlEncode(string value) - { - return $"UrlEncode[[{ value }]]"; - } - - public void UrlEncode(string value, int startIndex, int charCount, TextWriter output) - { - output.Write($"UrlEncode[[{ value.Substring(startIndex, charCount) }]]"); - } - - public void UrlEncode(char[] value, int startIndex, int charCount, TextWriter output) - { - output.Write("UrlEncode[["); - output.Write(value, startIndex, charCount); - output.Write("]]"); - } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/DefaultTemplatesUtilities.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/DefaultTemplatesUtilities.cs index f0d945b47d..f8f449641b 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/DefaultTemplatesUtilities.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/DefaultTemplatesUtilities.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Globalization; using System.IO; +using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNet.Antiforgery; using Microsoft.AspNet.Http.Internal; @@ -17,7 +18,6 @@ using Microsoft.AspNet.Mvc.ViewEngines; using Microsoft.AspNet.Mvc.ViewFeatures; using Microsoft.AspNet.Routing; using Microsoft.Extensions.OptionsModel; -using Microsoft.Extensions.WebEncoders; using Microsoft.Extensions.WebEncoders.Testing; using Moq; @@ -254,7 +254,7 @@ namespace Microsoft.AspNet.Mvc.Rendering optionsAccessor.Object, provider, urlHelper, - new CommonTestEncoder()); + new HtmlTestEncoder()); } // TemplateRenderer will Contextualize this transient service. @@ -262,9 +262,9 @@ namespace Microsoft.AspNet.Mvc.Rendering htmlGenerator, viewEngine, provider, - new CommonTestEncoder(), - new UrlEncoder(), - new JavaScriptStringEncoder()); + new HtmlTestEncoder(), + UrlEncoder.Default, + JavaScriptEncoder.Default); if (innerHelperWrapper != null) { @@ -278,9 +278,9 @@ namespace Microsoft.AspNet.Mvc.Rendering htmlGenerator, viewEngine, provider, - new CommonTestEncoder(), - new UrlEncoder(), - new JavaScriptStringEncoder()); + new HtmlTestEncoder(), + UrlEncoder.Default, + JavaScriptEncoder.Default); var viewContext = new ViewContext( actionContext, diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperCheckboxTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperCheckboxTest.cs index c3d30b0209..5d63afbee3 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperCheckboxTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperCheckboxTest.cs @@ -149,7 +149,7 @@ namespace Microsoft.AspNet.Mvc.Rendering Assert.Equal(expected, HtmlContentUtilities.HtmlContentToString(html)); var writer = new StringWriter(); var hiddenTag = Assert.Single(helper.ViewContext.FormContext.EndOfFormContent); - hiddenTag.WriteTo(writer, new CommonTestEncoder()); + hiddenTag.WriteTo(writer, new HtmlTestEncoder()); Assert.Equal("", writer.ToString()); } diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperFormTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperFormTest.cs index 0de46d3242..a1628c06b6 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperFormTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperFormTest.cs @@ -6,10 +6,10 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Text.Encodings.Web; using Microsoft.AspNet.Http; using Microsoft.AspNet.Mvc.Routing; using Microsoft.AspNet.Mvc.ViewFeatures; -using Microsoft.Extensions.WebEncoders; using Microsoft.Extensions.WebEncoders.Testing; using Moq; using Xunit; @@ -327,7 +327,7 @@ namespace Microsoft.AspNet.Mvc.Rendering // Arrange var htmlHelper = DefaultTemplatesUtilities.GetHtmlHelper(); var serviceProvider = new Mock(); - serviceProvider.Setup(s => s.GetService(typeof(IHtmlEncoder))).Returns(new CommonTestEncoder()); + serviceProvider.Setup(s => s.GetService(typeof(HtmlEncoder))).Returns(new HtmlTestEncoder()); var viewContext = htmlHelper.ViewContext; viewContext.HttpContext.RequestServices = serviceProvider.Object; diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperSelectTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperSelectTest.cs index 6da5f15d92..5f3cf9f91a 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperSelectTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperSelectTest.cs @@ -6,12 +6,12 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; +using System.Text.Encodings.Web; using Microsoft.AspNet.Mvc.ModelBinding; using Microsoft.AspNet.Mvc.TestCommon; using Microsoft.AspNet.Mvc.ViewEngines; using Microsoft.AspNet.Mvc.ViewFeatures; using Microsoft.AspNet.Testing; -using Microsoft.Extensions.WebEncoders; using Moq; using Xunit; @@ -1568,9 +1568,9 @@ namespace Microsoft.AspNet.Mvc.Rendering new Mock(MockBehavior.Strict).Object, new Mock(MockBehavior.Strict).Object, metadataProvider, - new Mock(MockBehavior.Strict).Object, - new Mock(MockBehavior.Strict).Object, - new Mock(MockBehavior.Strict).Object) + new Mock(MockBehavior.Strict).Object, + new Mock(MockBehavior.Strict).Object, + new Mock(MockBehavior.Strict).Object) { } diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlStringTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlStringTest.cs index bbdd4dae4e..29a479f899 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlStringTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlStringTest.cs @@ -18,7 +18,7 @@ namespace Microsoft.AspNet.Mvc.Rendering var writer = new StringWriter(); // Act - content.WriteTo(writer, new CommonTestEncoder()); + content.WriteTo(writer, new HtmlTestEncoder()); // Assert Assert.Equal(expectedText, writer.ToString()); diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/TagBuilderTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/TagBuilderTest.cs index db4448f305..b38f143010 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/TagBuilderTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/TagBuilderTest.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.IO; -using Microsoft.AspNet.Html.Abstractions; using Microsoft.AspNet.Mvc.Rendering; using Microsoft.Extensions.WebEncoders.Testing; using Xunit; @@ -85,7 +84,7 @@ namespace Microsoft.AspNet.Mvc.Core.Rendering // Act using (var writer = new StringWriter()) { - tagBuilder.WriteTo(writer, new NullTestEncoder()); + tagBuilder.WriteTo(writer, new HtmlTestEncoder()); // Assert Assert.Equal(expectedOutput, writer.ToString()); @@ -116,7 +115,7 @@ namespace Microsoft.AspNet.Mvc.Core.Rendering // Act using (var writer = new StringWriter()) { - tagBuilder.WriteTo(writer, new CommonTestEncoder()); + tagBuilder.WriteTo(writer, new HtmlTestEncoder()); // Assert Assert.Equal("

HelloHtmlEncode[[, World!]]

", writer.ToString()); diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewComponentTests.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewComponentTests.cs index 4e3c01a1d0..aa86de03e8 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewComponentTests.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewComponentTests.cs @@ -1,10 +1,10 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System.Text.Encodings.Web; using Microsoft.AspNet.Mvc.Rendering; using Microsoft.AspNet.Mvc.ViewComponents; using Microsoft.AspNet.Mvc.ViewFeatures; -using Microsoft.Extensions.WebEncoders; using Xunit; namespace Microsoft.AspNet.Mvc @@ -49,7 +49,7 @@ namespace Microsoft.AspNet.Mvc // Arrange var viewComponent = new TestViewComponent(); var expectedContent = "TestContent&"; - var expectedEncodedContent = new HtmlString(new HtmlEncoder().HtmlEncode(expectedContent)); + var expectedEncodedContent = new HtmlString(HtmlEncoder.Default.Encode(expectedContent)); // Act var actualResult = viewComponent.Content(expectedContent); diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/DefaultEditorTemplatesTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/DefaultEditorTemplatesTest.cs index de94dc89dd..fbae8c2fdf 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/DefaultEditorTemplatesTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/DefaultEditorTemplatesTest.cs @@ -8,6 +8,7 @@ using System.ComponentModel.DataAnnotations; using System.Globalization; using System.Linq; using System.Text; +using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNet.Html.Abstractions; using Microsoft.AspNet.Http; @@ -18,7 +19,6 @@ using Microsoft.AspNet.Mvc.TestCommon; using Microsoft.AspNet.Mvc.ViewEngines; using Microsoft.AspNet.Mvc.ViewFeatures.Internal; using Microsoft.AspNet.Testing; -using Microsoft.Extensions.WebEncoders; using Moq; using Xunit; @@ -919,14 +919,14 @@ Environment.NewLine; get { return _innerHelper.TempData; } } - public IUrlEncoder UrlEncoder + public UrlEncoder UrlEncoder { get { return _innerHelper.UrlEncoder; } } - public IJavaScriptStringEncoder JavaScriptStringEncoder + public JavaScriptEncoder JavaScriptEncoder { - get { return _innerHelper.JavaScriptStringEncoder; } + get { return _innerHelper.JavaScriptEncoder; } } public void Contextualize(ViewContext viewContext) diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/DefaultHtmlGeneratorTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/DefaultHtmlGeneratorTest.cs index 3b804faaba..35aefb46ae 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/DefaultHtmlGeneratorTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/DefaultHtmlGeneratorTest.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Text.Encodings.Web; using Microsoft.AspNet.Antiforgery; using Microsoft.AspNet.Http.Internal; using Microsoft.AspNet.Mvc.Abstractions; @@ -14,7 +15,6 @@ using Microsoft.AspNet.Mvc.Rendering; using Microsoft.AspNet.Mvc.ViewEngines; using Microsoft.AspNet.Routing; using Microsoft.Extensions.OptionsModel; -using Microsoft.Extensions.WebEncoders; using Moq; using Xunit; @@ -645,7 +645,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures { var mvcViewOptionsAccessor = new Mock>(); mvcViewOptionsAccessor.SetupGet(accessor => accessor.Value).Returns(new MvcViewOptions()); - var htmlEncoder = Mock.Of(); + var htmlEncoder = Mock.Of(); var antiforgery = Mock.Of(); var optionsAccessor = new Mock>(); diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/StringCollectionTextWriterTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/StringCollectionTextWriterTest.cs index 4e8f1a7ac2..8249a4e3bb 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/StringCollectionTextWriterTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/StringCollectionTextWriterTest.cs @@ -175,7 +175,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures // Act source.Write("Hello world"); source.Write(new char[1], 0, 1); - source.CopyTo(target, new CommonTestEncoder()); + source.CopyTo(target, new HtmlTestEncoder()); // Assert // Make sure content was written to the source. @@ -197,7 +197,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures // Act source.WriteLine("Hello world"); source.Write(new[] { 'x', 'a', 'b', 'c' }, 1, 3); - source.CopyTo(target, new CommonTestEncoder()); + source.CopyTo(target, new HtmlTestEncoder()); // Assert Assert.Equal(expected, target.ToString()); diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/StringHtmlContentTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/StringHtmlContentTest.cs index c470bfb6e2..3a677f85e7 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/StringHtmlContentTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/StringHtmlContentTest.cs @@ -18,7 +18,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures // Assert using (var writer = new StringWriter()) { - content.WriteTo(writer, new CommonTestEncoder()); + content.WriteTo(writer, new HtmlTestEncoder()); Assert.Equal("HtmlEncode[[Hello World]]", writer.ToString()); } } diff --git a/test/WebSites/ActivatorWebSite/TagHelpers/HiddenTagHelper.cs b/test/WebSites/ActivatorWebSite/TagHelpers/HiddenTagHelper.cs index a0e48bf734..cb4bfbb218 100644 --- a/test/WebSites/ActivatorWebSite/TagHelpers/HiddenTagHelper.cs +++ b/test/WebSites/ActivatorWebSite/TagHelpers/HiddenTagHelper.cs @@ -1,19 +1,19 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System.Text.Encodings.Web; using System.Threading.Tasks; using Microsoft.AspNet.Mvc.Rendering; using Microsoft.AspNet.Mvc.ViewFeatures; using Microsoft.AspNet.Mvc.ViewFeatures.Internal; using Microsoft.AspNet.Razor.TagHelpers; -using Microsoft.Extensions.WebEncoders; namespace ActivatorWebSite.TagHelpers { [HtmlTargetElement("span")] public class HiddenTagHelper : TagHelper { - public HiddenTagHelper(IHtmlHelper htmlHelper, IHtmlEncoder htmlEncoder) + public HiddenTagHelper(IHtmlHelper htmlHelper, HtmlEncoder htmlEncoder) { HtmlHelper = htmlHelper; HtmlEncoder = htmlEncoder; @@ -21,7 +21,7 @@ namespace ActivatorWebSite.TagHelpers public IHtmlHelper HtmlHelper { get; } - public IHtmlEncoder HtmlEncoder { get; } + public HtmlEncoder HtmlEncoder { get; } [HtmlAttributeNotBound] [ViewContext] diff --git a/test/WebSites/FiltersWebSite/AuthorizeBasicMiddleware.cs b/test/WebSites/FiltersWebSite/AuthorizeBasicMiddleware.cs index 22ce823aaf..92c4719f20 100644 --- a/test/WebSites/FiltersWebSite/AuthorizeBasicMiddleware.cs +++ b/test/WebSites/FiltersWebSite/AuthorizeBasicMiddleware.cs @@ -1,9 +1,9 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System.Text.Encodings.Web; using Microsoft.AspNet.Authentication; using Microsoft.AspNet.Builder; -using Microsoft.Extensions.WebEncoders; using Microsoft.Extensions.Logging; namespace FiltersWebSite @@ -13,7 +13,7 @@ namespace FiltersWebSite public AuthorizeBasicMiddleware( RequestDelegate next, ILoggerFactory loggerFactory, - IUrlEncoder encoder, + UrlEncoder encoder, string authScheme) : base(next, new BasicOptions { AuthenticationScheme = authScheme },