Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

using System.Collections.Specialized;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Net;
using System.Web.Hosting;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.SystemWebAdapters;
Expand Down Expand Up @@ -32,6 +34,11 @@ public string MapPath(string? path)

public void ClearError() => _context.AsSystemWeb().ClearError();

[return: NotNullIfNotNull(nameof(value))]
public string? HtmlEncode(string? value) => WebUtility.HtmlEncode(value);

public void HtmlEncode(string? value, TextWriter output) => WebUtility.HtmlEncode(value, output);

/// <summary>
/// This method is similar to <see cref="WebEncoders.Base64UrlDecode(string)"/> but handles the trailing character that <see cref="UrlTokenEncode(byte[])"/>
/// appends to the string.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics.CodeAnalysis;
using System.IO;

namespace System.Web;

Expand All @@ -10,6 +11,10 @@ public class HttpServerUtilityBase
{
public virtual string MachineName => throw new NotImplementedException();

public virtual string? HtmlEncode(string? value) => throw new NotImplementedException();

public virtual void HtmlEncode(string? value, TextWriter output) => throw new NotImplementedException();

public virtual string MapPath(string path) => throw new NotImplementedException();

public virtual Exception? GetLastError() => throw new NotImplementedException();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.IO;

namespace System.Web;

public class HttpServerUtilityWrapper : HttpServerUtilityBase
Expand All @@ -20,6 +22,10 @@ public HttpServerUtilityWrapper(HttpServerUtility utility)

public override string MachineName => _utility.MachineName;

public override string? HtmlEncode(string? value) => _utility.HtmlEncode(value);

public override void HtmlEncode(string? value, TextWriter output) => _utility.HtmlEncode(value, output);

public override string MapPath(string path) => _utility.MapPath(path);

public override byte[]? UrlTokenDecode(string input) => HttpServerUtility.UrlTokenDecode(input);
Expand Down