-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
106 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
using System.Text; | ||
using System.Web; | ||
using Microsoft.AspNetCore.Http; | ||
|
||
namespace Microsoft.SemanticWorkbench.Connector; | ||
|
||
public static class StringLoggingExtensions | ||
{ | ||
public static string HtmlEncode(this string? value) | ||
{ | ||
return string.IsNullOrWhiteSpace(value) | ||
? $"{value}" | ||
: HttpUtility.HtmlEncode(value); | ||
} | ||
|
||
public static string HtmlEncode(this PathString value) | ||
{ | ||
return string.IsNullOrWhiteSpace(value) | ||
? $"{value}" | ||
: HttpUtility.HtmlEncode(value); | ||
} | ||
|
||
public static string HtmlEncode(this StringBuilder value) | ||
{ | ||
var s = value.ToString(); | ||
return string.IsNullOrWhiteSpace(value.ToString()) | ||
? $"{s}" | ||
: HttpUtility.HtmlEncode(s); | ||
} | ||
|
||
public static string HtmlEncode(this object? value) | ||
{ | ||
return value == null | ||
? string.Empty | ||
: HttpUtility.HtmlEncode(value.ToString() ?? string.Empty); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.