├── korebuild-lock.txt
├── NuGetPackageVerifier.json
├── korebuild.json
├── CONTRIBUTING.md
├── .github
└── ISSUE_TEMPLATE.md
├── NuGet.config
├── run.cmd
├── .vsts-pipelines
└── builds
│ ├── ci-internal.yml
│ └── ci-public.yml
├── .appveyor.yml
├── README.md
├── test
├── Microsoft.AspNetCore.Html.Abstractions.Test
│ ├── Microsoft.AspNetCore.Html.Abstractions.Test.csproj
│ ├── HtmlFormattableStringTest.cs
│ ├── HtmlContentBuilderTest.cs
│ └── HtmlContentBuilderExtensionsTest.cs
├── Microsoft.Extensions.WebEncoders.Tests
│ ├── Microsoft.Extensions.WebEncoders.Tests.csproj
│ ├── HtmlTestEncoderTest.cs
│ └── EncoderServiceCollectionExtensionsTests.cs
└── Directory.Build.props
├── .gitignore
├── .travis.yml
├── src
├── Microsoft.AspNetCore.Html.Abstractions
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Microsoft.AspNetCore.Html.Abstractions.csproj
│ ├── IHtmlContent.cs
│ ├── IHtmlContentContainer.cs
│ ├── IHtmlContentBuilder.cs
│ ├── HtmlString.cs
│ ├── HtmlContentBuilder.cs
│ ├── HtmlFormattableString.cs
│ ├── HtmlContentBuilderExtensions.cs
│ └── baseline.netcore.json
└── Microsoft.Extensions.WebEncoders
│ ├── WebEncoderOptions.cs
│ ├── Microsoft.Extensions.WebEncoders.csproj
│ ├── Testing
│ ├── UrlTestEncoder.cs
│ ├── HtmlTestEncoder.cs
│ └── JavaScriptTestEncoder.cs
│ ├── EncoderServiceCollectionExtensions.cs
│ └── baseline.netcore.json
├── Directory.Build.targets
├── version.props
├── .gitattributes
├── Directory.Build.props
├── HtmlAbstractions.sln
├── run.ps1
├── run.sh
└── LICENSE.txt
/korebuild-lock.txt:
--------------------------------------------------------------------------------
1 | version:3.0.0-alpha1-20180919.1
2 | commithash:3066ae0a230870ea07e3f132605b5e5493f8bbd4
3 |
--------------------------------------------------------------------------------
/NuGetPackageVerifier.json:
--------------------------------------------------------------------------------
1 | {
2 | "Default": {
3 | "rules": [
4 | "DefaultCompositeRule"
5 | ]
6 | }
7 | }
--------------------------------------------------------------------------------
/korebuild.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/master/tools/korebuild.schema.json",
3 | "channel": "master"
4 | }
5 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | Contributing
2 | ======
3 |
4 | Information on contributing to this repo is in the [Contributing Guide](https://github.com/aspnet/Home/blob/master/CONTRIBUTING.md) in the Home repo.
5 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | THIS ISSUE TRACKER IS CLOSED - please log new issues here: https://github.com/aspnet/Home/issues
2 |
3 | For information about this change, see https://github.com/aspnet/Announcements/issues/283
4 |
--------------------------------------------------------------------------------
/NuGet.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/run.cmd:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 | PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0run.ps1' %*; exit $LASTEXITCODE"
3 |
--------------------------------------------------------------------------------
/.vsts-pipelines/builds/ci-internal.yml:
--------------------------------------------------------------------------------
1 | trigger:
2 | - master
3 | - release/*
4 |
5 | resources:
6 | repositories:
7 | - repository: buildtools
8 | type: git
9 | name: aspnet-BuildTools
10 | ref: refs/heads/master
11 |
12 | phases:
13 | - template: .vsts-pipelines/templates/project-ci.yml@buildtools
14 |
--------------------------------------------------------------------------------
/.appveyor.yml:
--------------------------------------------------------------------------------
1 | init:
2 | - git config --global core.autocrlf true
3 | branches:
4 | only:
5 | - master
6 | - /^release\/.*$/
7 | - /^(.*\/)?ci-.*$/
8 | build_script:
9 | - ps: .\run.ps1 default-build
10 | clone_depth: 1
11 | environment:
12 | global:
13 | DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
14 | DOTNET_CLI_TELEMETRY_OPTOUT: 1
15 | test: 'off'
16 | deploy: 'off'
17 | os: Visual Studio 2017
18 |
--------------------------------------------------------------------------------
/.vsts-pipelines/builds/ci-public.yml:
--------------------------------------------------------------------------------
1 | trigger:
2 | - master
3 | - release/*
4 |
5 | # See https://github.com/aspnet/BuildTools
6 | resources:
7 | repositories:
8 | - repository: buildtools
9 | type: github
10 | endpoint: DotNet-Bot GitHub Connection
11 | name: aspnet/BuildTools
12 | ref: refs/heads/master
13 |
14 | phases:
15 | - template: .vsts-pipelines/templates/project-ci.yml@buildtools
16 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | HtmlAbstractions [Archived]
2 | ===========================
3 |
4 | **This GitHub project has been archived.** Ongoing development on this project can be found in .
5 |
6 | HTML abstractions used for building HTML content, including types such as `HtmlString` and `IHtmlContent`.
7 |
8 | This project is part of ASP.NET Core. You can find samples, documentation and getting started instructions for ASP.NET Core at the [AspNetCore](https://github.com/aspnet/AspNetCore) repo.
9 |
--------------------------------------------------------------------------------
/test/Microsoft.AspNetCore.Html.Abstractions.Test/Microsoft.AspNetCore.Html.Abstractions.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(StandardTestTfms)
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/test/Microsoft.Extensions.WebEncoders.Tests/Microsoft.Extensions.WebEncoders.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(StandardTestTfms)
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | [Oo]bj/
2 | [Bb]in/
3 | TestResults/
4 | .nuget/
5 | *.sln.ide/
6 | _ReSharper.*/
7 | packages/
8 | artifacts/
9 | PublishProfiles/
10 | .vs/
11 | bower_components/
12 | node_modules/
13 | **/wwwroot/lib/
14 | debugSettings.json
15 | project.lock.json
16 | *.user
17 | *.suo
18 | *.cache
19 | *.docstates
20 | _ReSharper.*
21 | nuget.exe
22 | *net45.csproj
23 | *net451.csproj
24 | *k10.csproj
25 | *.psess
26 | *.vsp
27 | *.pidb
28 | *.userprefs
29 | *DS_Store
30 | *.ncrunchsolution
31 | *.*sdf
32 | *.ipch
33 | .settings
34 | *.sln.ide
35 | node_modules
36 | **/[Cc]ompiler/[Rr]esources/**/*.js
37 | *launchSettings.json
38 | .build/
39 | .testPublish/
40 | global.json
41 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: csharp
2 | sudo: false
3 | dist: trusty
4 | env:
5 | global:
6 | - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
7 | - DOTNET_CLI_TELEMETRY_OPTOUT: 1
8 | mono: none
9 | os:
10 | - linux
11 | - osx
12 | osx_image: xcode8.2
13 | addons:
14 | apt:
15 | packages:
16 | - libunwind8
17 | branches:
18 | only:
19 | - master
20 | - /^release\/.*$/
21 | - /^(.*\/)?ci-.*$/
22 | before_install:
23 | - if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s
24 | /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
25 | /usr/local/lib/; fi
26 | script:
27 | - ./build.sh
28 |
--------------------------------------------------------------------------------
/src/Microsoft.AspNetCore.Html.Abstractions/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Reflection;
5 | using System.Resources;
6 | using System.Runtime.CompilerServices;
7 |
8 | [assembly: InternalsVisibleTo("Microsoft.AspNetCore.Html.Abstractions.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
9 |
--------------------------------------------------------------------------------
/src/Microsoft.AspNetCore.Html.Abstractions/Microsoft.AspNetCore.Html.Abstractions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Microsoft ASP.NET Core
5 | ASP.NET Core HTML abstractions used for building HTML content.
6 | Commonly used types:
7 | Microsoft.AspNetCore.Html.HtmlString
8 | Microsoft.AspNetCore.Html.IHtmlContent
9 | netstandard2.0
10 | true
11 | aspnetcore
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 | $(MicrosoftNETCoreApp20PackageVersion)
4 | $(MicrosoftNETCoreApp21PackageVersion)
5 | $(MicrosoftNETCoreApp22PackageVersion)
6 | $(NETStandardLibrary20PackageVersion)
7 |
8 | 99.9
9 |
10 |
11 |
--------------------------------------------------------------------------------
/test/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | netcoreapp2.2
6 | $(DeveloperBuildTestTfms)
7 |
8 | $(StandardTestTfms);net461
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.WebEncoders/WebEncoderOptions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Text.Encodings.Web;
5 |
6 | namespace Microsoft.Extensions.WebEncoders
7 | {
8 | ///
9 | /// Specifies options common to all three encoders (HtmlEncode, JavaScriptEncode, UrlEncode).
10 | ///
11 | public sealed class WebEncoderOptions
12 | {
13 | ///
14 | /// Specifies which code points are allowed to be represented unescaped by the encoders.
15 | ///
16 | ///
17 | /// If this property is null, then the encoders will use their default allow lists.
18 | ///
19 | public TextEncoderSettings TextEncoderSettings { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/test/Microsoft.Extensions.WebEncoders.Tests/HtmlTestEncoderTest.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using Xunit;
5 |
6 | namespace Microsoft.Extensions.WebEncoders.Testing
7 | {
8 | public class HtmlTestEncoderTest
9 | {
10 | [Theory]
11 | [InlineData("", "")]
12 | [InlineData("abcd", "HtmlEncode[[abcd]]")]
13 | [InlineData("<<''\"\">>", "HtmlEncode[[<<''\"\">>]]")]
14 | public void StringEncode_EncodesAsExpected(string input, string expectedOutput)
15 | {
16 | // Arrange
17 | var encoder = new HtmlTestEncoder();
18 |
19 | // Act
20 | var output = encoder.Encode(input);
21 |
22 | // Assert
23 | Assert.Equal(expectedOutput, output);
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Microsoft.AspNetCore.Html.Abstractions/IHtmlContent.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.IO;
5 | using System.Text.Encodings.Web;
6 |
7 | namespace Microsoft.AspNetCore.Html
8 | {
9 | ///
10 | /// HTML content which can be written to a TextWriter.
11 | ///
12 | public interface IHtmlContent
13 | {
14 | ///
15 | /// Writes the content by encoding it with the specified
16 | /// to the specified .
17 | ///
18 | /// The to which the content is written.
19 | /// The which encodes the content to be written.
20 | void WriteTo(TextWriter writer, HtmlEncoder encoder);
21 | }
22 | }
--------------------------------------------------------------------------------
/version.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | 3.0.0
4 | alpha1
5 | $(VersionPrefix)
6 | $(VersionPrefix)-$(VersionSuffix)-final
7 | t000
8 | a-
9 | $(FeatureBranchVersionPrefix)$(VersionSuffix)-$([System.Text.RegularExpressions.Regex]::Replace('$(FeatureBranchVersionSuffix)', '[^\w-]', '-'))
10 | $(VersionSuffix)-$(BuildNumber)
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.doc diff=astextplain
2 | *.DOC diff=astextplain
3 | *.docx diff=astextplain
4 | *.DOCX diff=astextplain
5 | *.dot diff=astextplain
6 | *.DOT diff=astextplain
7 | *.pdf diff=astextplain
8 | *.PDF diff=astextplain
9 | *.rtf diff=astextplain
10 | *.RTF diff=astextplain
11 |
12 | *.jpg binary
13 | *.png binary
14 | *.gif binary
15 |
16 | *.cs text=auto diff=csharp
17 | *.vb text=auto
18 | *.resx text=auto
19 | *.c text=auto
20 | *.cpp text=auto
21 | *.cxx text=auto
22 | *.h text=auto
23 | *.hxx text=auto
24 | *.py text=auto
25 | *.rb text=auto
26 | *.java text=auto
27 | *.html text=auto
28 | *.htm text=auto
29 | *.css text=auto
30 | *.scss text=auto
31 | *.sass text=auto
32 | *.less text=auto
33 | *.js text=auto
34 | *.lisp text=auto
35 | *.clj text=auto
36 | *.sql text=auto
37 | *.php text=auto
38 | *.lua text=auto
39 | *.m text=auto
40 | *.asm text=auto
41 | *.erl text=auto
42 | *.fs text=auto
43 | *.fsx text=auto
44 | *.hs text=auto
45 |
46 | *.csproj text=auto
47 | *.vbproj text=auto
48 | *.fsproj text=auto
49 | *.dbproj text=auto
50 | *.sln text=auto eol=crlf
51 | *.sh eol=lf
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.WebEncoders/Microsoft.Extensions.WebEncoders.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Microsoft .NET Extensions
5 | Contains registration and configuration APIs to add the core framework encoders to a dependency injection container.
6 | netstandard2.0
7 | $(NoWarn);CS1591
8 | true
9 | true
10 | aspnetcore
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | https://github.com/aspnet/HtmlAbstractions
12 | git
13 | $(MSBuildThisFileDirectory)
14 | $(MSBuildThisFileDirectory)build\Key.snk
15 | true
16 | true
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/Microsoft.AspNetCore.Html.Abstractions/IHtmlContentContainer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | namespace Microsoft.AspNetCore.Html
5 | {
6 | ///
7 | /// Defines a contract for instances made up of several components which
8 | /// can be copied into an .
9 | ///
10 | public interface IHtmlContentContainer : IHtmlContent
11 | {
12 | ///
13 | /// Copies the contained content of this into .
14 | ///
15 | /// The .
16 | void CopyTo(IHtmlContentBuilder builder);
17 |
18 | ///
19 | ///
20 | /// Moves the contained content of this into .
21 | ///
22 | ///
23 | /// After is called, this instance should be left
24 | /// in an empty state.
25 | ///
26 | ///
27 | /// The .
28 | void MoveTo(IHtmlContentBuilder builder);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Microsoft.AspNetCore.Html.Abstractions/IHtmlContentBuilder.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | namespace Microsoft.AspNetCore.Html
5 | {
6 | ///
7 | /// A builder for HTML content.
8 | ///
9 | public interface IHtmlContentBuilder : IHtmlContentContainer
10 | {
11 | ///
12 | /// Appends an instance.
13 | ///
14 | /// The to append.
15 | /// The .
16 | IHtmlContentBuilder AppendHtml(IHtmlContent content);
17 |
18 | ///
19 | /// Appends a value. The value is treated as unencoded as-provided, and will be HTML
20 | /// encoded before writing to output.
21 | ///
22 | /// The to append.
23 | /// The .
24 | IHtmlContentBuilder Append(string unencoded);
25 |
26 | ///
27 | /// Appends an HTML encoded value. The value is treated as HTML encoded as-provided, and
28 | /// no further encoding will be performed.
29 | ///
30 | /// The HTML encoded to append.
31 | /// The .
32 | IHtmlContentBuilder AppendHtml(string encoded);
33 |
34 | ///
35 | /// Clears the content.
36 | ///
37 | /// The .
38 | IHtmlContentBuilder Clear();
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/Microsoft.AspNetCore.Html.Abstractions/HtmlString.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.IO;
6 | using System.Text.Encodings.Web;
7 |
8 | namespace Microsoft.AspNetCore.Html
9 | {
10 | ///
11 | /// An implementation that wraps an HTML encoded .
12 | ///
13 | public class HtmlString : IHtmlContent
14 | {
15 | ///
16 | /// An instance for .
17 | ///
18 | public static readonly HtmlString NewLine = new HtmlString(Environment.NewLine);
19 |
20 | ///
21 | /// An instance for .
22 | ///
23 | public static readonly HtmlString Empty = new HtmlString(string.Empty);
24 |
25 | ///
26 | /// Creates a new .
27 | ///
28 | /// The HTML encoded value.
29 | public HtmlString(string value)
30 | {
31 | Value = value;
32 | }
33 |
34 | ///
35 | /// Gets the HTML encoded value.
36 | ///
37 | public string Value { get; }
38 |
39 | ///
40 | public void WriteTo(TextWriter writer, HtmlEncoder encoder)
41 | {
42 | if (writer == null)
43 | {
44 | throw new ArgumentNullException(nameof(writer));
45 | }
46 |
47 | if (encoder == null)
48 | {
49 | throw new ArgumentNullException(nameof(encoder));
50 | }
51 |
52 | writer.Write(Value);
53 | }
54 |
55 | ///
56 | public override string ToString()
57 | {
58 | return Value ?? string.Empty;
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.WebEncoders/Testing/UrlTestEncoder.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.IO;
6 | using System.Text.Encodings.Web;
7 |
8 | namespace Microsoft.Extensions.WebEncoders.Testing
9 | {
10 | ///
11 | /// Encoder used for unit testing.
12 | ///
13 | public class UrlTestEncoder : UrlEncoder
14 | {
15 | public override int MaxOutputCharactersPerInputCharacter
16 | {
17 | get { return 1; }
18 | }
19 |
20 | public override string Encode(string value)
21 | {
22 | if (value == null)
23 | {
24 | throw new ArgumentNullException(nameof(value));
25 | }
26 |
27 | if (value.Length == 0)
28 | {
29 | return string.Empty;
30 | }
31 |
32 | return $"UrlEncode[[{value}]]";
33 | }
34 |
35 | public override void Encode(TextWriter output, char[] value, int startIndex, int characterCount)
36 | {
37 | if (output == null)
38 | {
39 | throw new ArgumentNullException(nameof(output));
40 | }
41 |
42 | if (value == null)
43 | {
44 | throw new ArgumentNullException(nameof(value));
45 | }
46 |
47 | if (characterCount == 0)
48 | {
49 | return;
50 | }
51 |
52 | output.Write("UrlEncode[[");
53 | output.Write(value, startIndex, characterCount);
54 | output.Write("]]");
55 | }
56 |
57 | public override void Encode(TextWriter output, string value, int startIndex, int characterCount)
58 | {
59 | if (output == null)
60 | {
61 | throw new ArgumentNullException(nameof(output));
62 | }
63 |
64 | if (value == null)
65 | {
66 | throw new ArgumentNullException(nameof(value));
67 | }
68 |
69 | if (characterCount == 0)
70 | {
71 | return;
72 | }
73 |
74 | output.Write("UrlEncode[[");
75 | output.Write(value.Substring(startIndex, characterCount));
76 | output.Write("]]");
77 | }
78 |
79 | public override bool WillEncode(int unicodeScalar)
80 | {
81 | return false;
82 | }
83 |
84 | public override unsafe int FindFirstCharacterToEncode(char* text, int textLength)
85 | {
86 | return -1;
87 | }
88 |
89 | public override unsafe bool TryEncodeUnicodeScalar(
90 | int unicodeScalar,
91 | char* buffer,
92 | int bufferLength,
93 | out int numberOfCharactersWritten)
94 | {
95 | if (buffer == null)
96 | {
97 | throw new ArgumentNullException(nameof(buffer));
98 | }
99 |
100 | numberOfCharactersWritten = 0;
101 | return false;
102 | }
103 | }
104 | }
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.WebEncoders/Testing/HtmlTestEncoder.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.IO;
6 | using System.Text.Encodings.Web;
7 |
8 | namespace Microsoft.Extensions.WebEncoders.Testing
9 | {
10 | ///
11 | /// Encoder used for unit testing.
12 | ///
13 | public sealed class HtmlTestEncoder : HtmlEncoder
14 | {
15 | public override int MaxOutputCharactersPerInputCharacter
16 | {
17 | get { return 1; }
18 | }
19 |
20 | public override string Encode(string value)
21 | {
22 | if (value == null)
23 | {
24 | throw new ArgumentNullException(nameof(value));
25 | }
26 |
27 | if (value.Length == 0)
28 | {
29 | return string.Empty;
30 | }
31 |
32 | return $"HtmlEncode[[{value}]]";
33 | }
34 |
35 | public override void Encode(TextWriter output, char[] value, int startIndex, int characterCount)
36 | {
37 | if (output == null)
38 | {
39 | throw new ArgumentNullException(nameof(output));
40 | }
41 |
42 | if (value == null)
43 | {
44 | throw new ArgumentNullException(nameof(value));
45 | }
46 |
47 | if (characterCount == 0)
48 | {
49 | return;
50 | }
51 |
52 | output.Write("HtmlEncode[[");
53 | output.Write(value, startIndex, characterCount);
54 | output.Write("]]");
55 | }
56 |
57 | public override void Encode(TextWriter output, string value, int startIndex, int characterCount)
58 | {
59 | if (output == null)
60 | {
61 | throw new ArgumentNullException(nameof(output));
62 | }
63 |
64 | if (value == null)
65 | {
66 | throw new ArgumentNullException(nameof(value));
67 | }
68 |
69 | if (characterCount == 0)
70 | {
71 | return;
72 | }
73 |
74 | output.Write("HtmlEncode[[");
75 | output.Write(value.Substring(startIndex, characterCount));
76 | output.Write("]]");
77 | }
78 |
79 | public override bool WillEncode(int unicodeScalar)
80 | {
81 | return false;
82 | }
83 |
84 | public override unsafe int FindFirstCharacterToEncode(char* text, int textLength)
85 | {
86 | return -1;
87 | }
88 |
89 | public override unsafe bool TryEncodeUnicodeScalar(
90 | int unicodeScalar,
91 | char* buffer,
92 | int bufferLength,
93 | out int numberOfCharactersWritten)
94 | {
95 | if (buffer == null)
96 | {
97 | throw new ArgumentNullException(nameof(buffer));
98 | }
99 |
100 | numberOfCharactersWritten = 0;
101 | return false;
102 | }
103 | }
104 | }
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.WebEncoders/Testing/JavaScriptTestEncoder.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.IO;
6 | using System.Text.Encodings.Web;
7 |
8 | namespace Microsoft.Extensions.WebEncoders.Testing
9 | {
10 | ///
11 | /// Encoder used for unit testing.
12 | ///
13 | public class JavaScriptTestEncoder : JavaScriptEncoder
14 | {
15 | public override int MaxOutputCharactersPerInputCharacter
16 | {
17 | get { return 1; }
18 | }
19 |
20 | public override string Encode(string value)
21 | {
22 | if (value == null)
23 | {
24 | throw new ArgumentNullException(nameof(value));
25 | }
26 |
27 | if (value.Length == 0)
28 | {
29 | return string.Empty;
30 | }
31 |
32 | return $"JavaScriptEncode[[{value}]]";
33 | }
34 |
35 | public override void Encode(TextWriter output, char[] value, int startIndex, int characterCount)
36 | {
37 | if (output == null)
38 | {
39 | throw new ArgumentNullException(nameof(output));
40 | }
41 |
42 | if (value == null)
43 | {
44 | throw new ArgumentNullException(nameof(value));
45 | }
46 |
47 | if (characterCount == 0)
48 | {
49 | return;
50 | }
51 |
52 | output.Write("JavaScriptEncode[[");
53 | output.Write(value, startIndex, characterCount);
54 | output.Write("]]");
55 | }
56 |
57 | public override void Encode(TextWriter output, string value, int startIndex, int characterCount)
58 | {
59 | if (output == null)
60 | {
61 | throw new ArgumentNullException(nameof(output));
62 | }
63 |
64 | if (value == null)
65 | {
66 | throw new ArgumentNullException(nameof(value));
67 | }
68 |
69 | if (characterCount == 0)
70 | {
71 | return;
72 | }
73 |
74 | output.Write("JavaScriptEncode[[");
75 | output.Write(value.Substring(startIndex, characterCount));
76 | output.Write("]]");
77 | }
78 |
79 | public override bool WillEncode(int unicodeScalar)
80 | {
81 | return false;
82 | }
83 |
84 | public override unsafe int FindFirstCharacterToEncode(char* text, int textLength)
85 | {
86 | return -1;
87 | }
88 |
89 | public override unsafe bool TryEncodeUnicodeScalar(
90 | int unicodeScalar,
91 | char* buffer,
92 | int bufferLength,
93 | out int numberOfCharactersWritten)
94 | {
95 | if (buffer == null)
96 | {
97 | throw new ArgumentNullException(nameof(buffer));
98 | }
99 |
100 | numberOfCharactersWritten = 0;
101 | return false;
102 | }
103 | }
104 | }
--------------------------------------------------------------------------------
/src/Microsoft.Extensions.WebEncoders/EncoderServiceCollectionExtensions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.Text.Encodings.Web;
6 | using Microsoft.Extensions.DependencyInjection.Extensions;
7 | using Microsoft.Extensions.Options;
8 | using Microsoft.Extensions.WebEncoders;
9 |
10 | namespace Microsoft.Extensions.DependencyInjection
11 | {
12 | ///
13 | /// Extension methods for setting up web encoding services in an .
14 | ///
15 | public static class EncoderServiceCollectionExtensions
16 | {
17 | ///
18 | /// Adds , and
19 | /// to the specified .
20 | ///
21 | /// The .
22 | /// The so that additional calls can be chained.
23 | public static IServiceCollection AddWebEncoders(this IServiceCollection services)
24 | {
25 | if (services == null)
26 | {
27 | throw new ArgumentNullException(nameof(services));
28 | }
29 |
30 | services.AddOptions();
31 |
32 | // Register the default encoders
33 | // We want to call the 'Default' property getters lazily since they perform static caching
34 | services.TryAddSingleton(
35 | CreateFactory(() => HtmlEncoder.Default, settings => HtmlEncoder.Create(settings)));
36 | services.TryAddSingleton(
37 | CreateFactory(() => JavaScriptEncoder.Default, settings => JavaScriptEncoder.Create(settings)));
38 | services.TryAddSingleton(
39 | CreateFactory(() => UrlEncoder.Default, settings => UrlEncoder.Create(settings)));
40 |
41 | return services;
42 | }
43 |
44 | ///
45 | /// Adds , and
46 | /// to the specified .
47 | ///
48 | /// The .
49 | /// An to configure the provided .
50 | /// The so that additional calls can be chained.
51 | public static IServiceCollection AddWebEncoders(this IServiceCollection services, Action setupAction)
52 | {
53 | if (services == null)
54 | {
55 | throw new ArgumentNullException(nameof(services));
56 | }
57 |
58 | if (setupAction == null)
59 | {
60 | throw new ArgumentNullException(nameof(setupAction));
61 | }
62 |
63 | services.AddWebEncoders();
64 | services.Configure(setupAction);
65 |
66 | return services;
67 | }
68 |
69 | private static Func CreateFactory(
70 | Func defaultFactory,
71 | Func customSettingsFactory)
72 | {
73 | return serviceProvider =>
74 | {
75 | var settings = serviceProvider
76 | ?.GetService>()
77 | ?.Value
78 | ?.TextEncoderSettings;
79 | return (settings != null) ? customSettingsFactory(settings) : defaultFactory();
80 | };
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/test/Microsoft.Extensions.WebEncoders.Tests/EncoderServiceCollectionExtensionsTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System.Text.Encodings.Web;
5 | using Microsoft.Extensions.DependencyInjection;
6 | using Microsoft.Extensions.WebEncoders.Testing;
7 | using Xunit;
8 |
9 | namespace Microsoft.Extensions.WebEncoders
10 | {
11 | public class EncoderServiceCollectionExtensionsTests
12 | {
13 | [Fact]
14 | public void AddWebEncoders_WithoutOptions_RegistersDefaultEncoders()
15 | {
16 | // Arrange
17 | var serviceCollection = new ServiceCollection();
18 |
19 | // Act
20 | serviceCollection.AddWebEncoders();
21 |
22 | // Assert
23 | var serviceProvider = serviceCollection.BuildServiceProvider();
24 | Assert.Same(HtmlEncoder.Default, serviceProvider.GetRequiredService()); // default encoder
25 | Assert.Same(HtmlEncoder.Default, serviceProvider.GetRequiredService()); // as singleton instance
26 | Assert.Same(JavaScriptEncoder.Default, serviceProvider.GetRequiredService()); // default encoder
27 | Assert.Same(JavaScriptEncoder.Default, serviceProvider.GetRequiredService()); // as singleton instance
28 | Assert.Same(UrlEncoder.Default, serviceProvider.GetRequiredService()); // default encoder
29 | Assert.Same(UrlEncoder.Default, serviceProvider.GetRequiredService()); // as singleton instance
30 | }
31 |
32 | [Fact]
33 | public void AddWebEncoders_WithOptions_RegistersEncodersWithCustomCodeFilter()
34 | {
35 | // Arrange
36 | var serviceCollection = new ServiceCollection();
37 |
38 | // Act
39 | serviceCollection.AddWebEncoders(options =>
40 | {
41 | options.TextEncoderSettings = new TextEncoderSettings();
42 | options.TextEncoderSettings.AllowCharacters("ace".ToCharArray()); // only these three chars are allowed
43 | });
44 |
45 | // Assert
46 | var serviceProvider = serviceCollection.BuildServiceProvider();
47 |
48 | var htmlEncoder = serviceProvider.GetRequiredService();
49 | Assert.Equal("abcde", htmlEncoder.Encode("abcde"));
50 | Assert.Same(htmlEncoder, serviceProvider.GetRequiredService()); // as singleton instance
51 |
52 | var javaScriptEncoder = serviceProvider.GetRequiredService();
53 | Assert.Equal(@"a\u0062c\u0064e", javaScriptEncoder.Encode("abcde"));
54 | Assert.Same(javaScriptEncoder, serviceProvider.GetRequiredService()); // as singleton instance
55 |
56 | var urlEncoder = serviceProvider.GetRequiredService();
57 | Assert.Equal("a%62c%64e", urlEncoder.Encode("abcde"));
58 | Assert.Same(urlEncoder, serviceProvider.GetRequiredService()); // as singleton instance
59 | }
60 |
61 | [Fact]
62 | public void AddWebEncoders_DoesNotOverrideExistingRegisteredEncoders()
63 | {
64 | // Arrange
65 | var serviceCollection = new ServiceCollection();
66 |
67 | // Act
68 | serviceCollection.AddSingleton();
69 | serviceCollection.AddSingleton();
70 | // we don't register an existing URL encoder
71 | serviceCollection.AddWebEncoders(options =>
72 | {
73 | options.TextEncoderSettings = new TextEncoderSettings();
74 | options.TextEncoderSettings.AllowCharacters("ace".ToCharArray()); // only these three chars are allowed
75 | });
76 |
77 | // Assert
78 | var serviceProvider = serviceCollection.BuildServiceProvider();
79 |
80 | var htmlEncoder = serviceProvider.GetRequiredService();
81 | Assert.Equal("HtmlEncode[[abcde]]", htmlEncoder.Encode("abcde"));
82 |
83 | var javaScriptEncoder = serviceProvider.GetRequiredService();
84 | Assert.Equal("JavaScriptEncode[[abcde]]", javaScriptEncoder.Encode("abcde"));
85 |
86 | var urlEncoder = serviceProvider.GetRequiredService();
87 | Assert.Equal("a%62c%64e", urlEncoder.Encode("abcde"));
88 | }
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/HtmlAbstractions.sln:
--------------------------------------------------------------------------------
1 | Microsoft Visual Studio Solution File, Format Version 12.00
2 | # Visual Studio 15
3 | VisualStudioVersion = 15.0.26127.0
4 | MinimumVisualStudioVersion = 15.0.26730.03
5 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A5A15F1C-885A-452A-A731-B0173DDBD913}"
6 | EndProject
7 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{F31FF137-390C-49BF-A3BD-7C6ED3597C21}"
8 | EndProject
9 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.Html.Abstractions", "src\Microsoft.AspNetCore.Html.Abstractions\Microsoft.AspNetCore.Html.Abstractions.csproj", "{68A28E4A-3ADE-4187-9625-4FF185887CB3}"
10 | EndProject
11 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.Html.Abstractions.Test", "test\Microsoft.AspNetCore.Html.Abstractions.Test\Microsoft.AspNetCore.Html.Abstractions.Test.csproj", "{2D187B88-94BD-4A39-AC97-F8F8B9363301}"
12 | EndProject
13 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B4962A29-BE69-4A18-9B4F-B803EEE31EAA}"
14 | ProjectSection(SolutionItems) = preProject
15 | NuGetPackageVerifier.json = NuGetPackageVerifier.json
16 | EndProjectSection
17 | EndProject
18 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Extensions.WebEncoders", "src\Microsoft.Extensions.WebEncoders\Microsoft.Extensions.WebEncoders.csproj", "{DD2CE416-765E-4000-A03E-C2FF165DA1B6}"
19 | EndProject
20 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Extensions.WebEncoders.Tests", "test\Microsoft.Extensions.WebEncoders.Tests\Microsoft.Extensions.WebEncoders.Tests.csproj", "{7AE2731D-43CD-4CF8-850A-4914DE2CE930}"
21 | EndProject
22 | Global
23 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
24 | Debug|Any CPU = Debug|Any CPU
25 | Debug|Mixed Platforms = Debug|Mixed Platforms
26 | Debug|x86 = Debug|x86
27 | Release|Any CPU = Release|Any CPU
28 | Release|Mixed Platforms = Release|Mixed Platforms
29 | Release|x86 = Release|x86
30 | EndGlobalSection
31 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
32 | {68A28E4A-3ADE-4187-9625-4FF185887CB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33 | {68A28E4A-3ADE-4187-9625-4FF185887CB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
34 | {68A28E4A-3ADE-4187-9625-4FF185887CB3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
35 | {68A28E4A-3ADE-4187-9625-4FF185887CB3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
36 | {68A28E4A-3ADE-4187-9625-4FF185887CB3}.Debug|x86.ActiveCfg = Debug|Any CPU
37 | {68A28E4A-3ADE-4187-9625-4FF185887CB3}.Debug|x86.Build.0 = Debug|Any CPU
38 | {68A28E4A-3ADE-4187-9625-4FF185887CB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
39 | {68A28E4A-3ADE-4187-9625-4FF185887CB3}.Release|Any CPU.Build.0 = Release|Any CPU
40 | {68A28E4A-3ADE-4187-9625-4FF185887CB3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
41 | {68A28E4A-3ADE-4187-9625-4FF185887CB3}.Release|Mixed Platforms.Build.0 = Release|Any CPU
42 | {68A28E4A-3ADE-4187-9625-4FF185887CB3}.Release|x86.ActiveCfg = Release|Any CPU
43 | {68A28E4A-3ADE-4187-9625-4FF185887CB3}.Release|x86.Build.0 = Release|Any CPU
44 | {2D187B88-94BD-4A39-AC97-F8F8B9363301}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
45 | {2D187B88-94BD-4A39-AC97-F8F8B9363301}.Debug|Any CPU.Build.0 = Debug|Any CPU
46 | {2D187B88-94BD-4A39-AC97-F8F8B9363301}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
47 | {2D187B88-94BD-4A39-AC97-F8F8B9363301}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
48 | {2D187B88-94BD-4A39-AC97-F8F8B9363301}.Debug|x86.ActiveCfg = Debug|Any CPU
49 | {2D187B88-94BD-4A39-AC97-F8F8B9363301}.Debug|x86.Build.0 = Debug|Any CPU
50 | {2D187B88-94BD-4A39-AC97-F8F8B9363301}.Release|Any CPU.ActiveCfg = Release|Any CPU
51 | {2D187B88-94BD-4A39-AC97-F8F8B9363301}.Release|Any CPU.Build.0 = Release|Any CPU
52 | {2D187B88-94BD-4A39-AC97-F8F8B9363301}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
53 | {2D187B88-94BD-4A39-AC97-F8F8B9363301}.Release|Mixed Platforms.Build.0 = Release|Any CPU
54 | {2D187B88-94BD-4A39-AC97-F8F8B9363301}.Release|x86.ActiveCfg = Release|Any CPU
55 | {2D187B88-94BD-4A39-AC97-F8F8B9363301}.Release|x86.Build.0 = Release|Any CPU
56 | {DD2CE416-765E-4000-A03E-C2FF165DA1B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
57 | {DD2CE416-765E-4000-A03E-C2FF165DA1B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
58 | {DD2CE416-765E-4000-A03E-C2FF165DA1B6}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
59 | {DD2CE416-765E-4000-A03E-C2FF165DA1B6}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
60 | {DD2CE416-765E-4000-A03E-C2FF165DA1B6}.Debug|x86.ActiveCfg = Debug|Any CPU
61 | {DD2CE416-765E-4000-A03E-C2FF165DA1B6}.Debug|x86.Build.0 = Debug|Any CPU
62 | {DD2CE416-765E-4000-A03E-C2FF165DA1B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
63 | {DD2CE416-765E-4000-A03E-C2FF165DA1B6}.Release|Any CPU.Build.0 = Release|Any CPU
64 | {DD2CE416-765E-4000-A03E-C2FF165DA1B6}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
65 | {DD2CE416-765E-4000-A03E-C2FF165DA1B6}.Release|Mixed Platforms.Build.0 = Release|Any CPU
66 | {DD2CE416-765E-4000-A03E-C2FF165DA1B6}.Release|x86.ActiveCfg = Release|Any CPU
67 | {DD2CE416-765E-4000-A03E-C2FF165DA1B6}.Release|x86.Build.0 = Release|Any CPU
68 | {7AE2731D-43CD-4CF8-850A-4914DE2CE930}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
69 | {7AE2731D-43CD-4CF8-850A-4914DE2CE930}.Debug|Any CPU.Build.0 = Debug|Any CPU
70 | {7AE2731D-43CD-4CF8-850A-4914DE2CE930}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
71 | {7AE2731D-43CD-4CF8-850A-4914DE2CE930}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
72 | {7AE2731D-43CD-4CF8-850A-4914DE2CE930}.Debug|x86.ActiveCfg = Debug|Any CPU
73 | {7AE2731D-43CD-4CF8-850A-4914DE2CE930}.Debug|x86.Build.0 = Debug|Any CPU
74 | {7AE2731D-43CD-4CF8-850A-4914DE2CE930}.Release|Any CPU.ActiveCfg = Release|Any CPU
75 | {7AE2731D-43CD-4CF8-850A-4914DE2CE930}.Release|Any CPU.Build.0 = Release|Any CPU
76 | {7AE2731D-43CD-4CF8-850A-4914DE2CE930}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
77 | {7AE2731D-43CD-4CF8-850A-4914DE2CE930}.Release|Mixed Platforms.Build.0 = Release|Any CPU
78 | {7AE2731D-43CD-4CF8-850A-4914DE2CE930}.Release|x86.ActiveCfg = Release|Any CPU
79 | {7AE2731D-43CD-4CF8-850A-4914DE2CE930}.Release|x86.Build.0 = Release|Any CPU
80 | EndGlobalSection
81 | GlobalSection(SolutionProperties) = preSolution
82 | HideSolutionNode = FALSE
83 | EndGlobalSection
84 | GlobalSection(NestedProjects) = preSolution
85 | {68A28E4A-3ADE-4187-9625-4FF185887CB3} = {A5A15F1C-885A-452A-A731-B0173DDBD913}
86 | {2D187B88-94BD-4A39-AC97-F8F8B9363301} = {F31FF137-390C-49BF-A3BD-7C6ED3597C21}
87 | {DD2CE416-765E-4000-A03E-C2FF165DA1B6} = {A5A15F1C-885A-452A-A731-B0173DDBD913}
88 | {7AE2731D-43CD-4CF8-850A-4914DE2CE930} = {F31FF137-390C-49BF-A3BD-7C6ED3597C21}
89 | EndGlobalSection
90 | EndGlobal
91 |
--------------------------------------------------------------------------------
/src/Microsoft.AspNetCore.Html.Abstractions/HtmlContentBuilder.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) .NET Foundation. All rights reserved.
2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 | using System.IO;
7 | using System.Text.Encodings.Web;
8 |
9 | namespace Microsoft.AspNetCore.Html
10 | {
11 | ///
12 | /// An implementation using an in memory list.
13 | ///
14 | public class HtmlContentBuilder : IHtmlContentBuilder
15 | {
16 | ///
17 | /// Creates a new .
18 | ///
19 | public HtmlContentBuilder()
20 | : this(new List