We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0b19fb2 commit 9ae9832Copy full SHA for 9ae9832
src/libraries/System.Web.HttpUtility/src/System/Web/Util/HttpEncoder.cs
@@ -125,15 +125,10 @@ private static int IndexOfHtmlAttributeEncodingChars(string s) =>
125
126
internal static string JavaScriptStringEncode(string? value, bool addDoubleQuotes)
127
{
128
- if (string.IsNullOrEmpty(value))
129
- {
130
- return addDoubleQuotes ? @"""""" : string.Empty;
131
- }
132
-
133
int i = value.AsSpan().IndexOfAny(s_invalidJavaScriptChars);
134
if (i < 0)
135
136
- return addDoubleQuotes ? $"\"{value}\"" : value;
+ return addDoubleQuotes ? $"\"{value}\"" : value ?? string.Empty;
137
}
138
139
return EncodeCore(value, i, addDoubleQuotes);
0 commit comments