| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System.Buffers; |
| | | 5 | | using System.Buffers.Text; |
| | | 6 | | using System.Diagnostics; |
| | | 7 | | using System.Text.Encodings.Web; |
| | | 8 | | |
| | | 9 | | #if !NET |
| | | 10 | | using System.Runtime.CompilerServices; |
| | | 11 | | #endif |
| | | 12 | | |
| | | 13 | | namespace System.Text.Json |
| | | 14 | | { |
| | | 15 | | internal static partial class JsonWriterHelper |
| | | 16 | | { |
| | | 17 | | // Only allow ASCII characters between ' ' (0x20) and '~' (0x7E), inclusively, |
| | | 18 | | // but exclude characters that need to be escaped as hex: '"', '\'', '&', '+', '<', '>', '`' |
| | | 19 | | // and exclude characters that need to be escaped by adding a backslash: '\n', '\r', '\t', '\\', '\b', '\f' |
| | | 20 | | // |
| | | 21 | | // non-zero = allowed, 0 = disallowed |
| | | 22 | | // This exactly matches the set used by JavaScriptEncoder.Default. |
| | | 23 | | // SearchValues instances below also represent the same ASCII set, validated to match in the debug static ctor b |
| | | 24 | | public const int LastAsciiCharacter = 0x7F; |
| | | 25 | | private static ReadOnlySpan<byte> AllowList => // byte.MaxValue + 1 |
| | 0 | 26 | | [ |
| | 0 | 27 | | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // U+0000..U+000F |
| | 0 | 28 | | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // U+0010..U+001F |
| | 0 | 29 | | 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, // U+0020..U+002F |
| | 0 | 30 | | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, // U+0030..U+003F |
| | 0 | 31 | | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // U+0040..U+004F |
| | 0 | 32 | | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, // U+0050..U+005F |
| | 0 | 33 | | 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // U+0060..U+006F |
| | 0 | 34 | | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, // U+0070..U+007F |
| | 0 | 35 | | |
| | 0 | 36 | | // Also include the ranges from U+0080 to U+00FF for performance to avoid UTF8 code from checking boundary. |
| | 0 | 37 | | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| | 0 | 38 | | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| | 0 | 39 | | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| | 0 | 40 | | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| | 0 | 41 | | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| | 0 | 42 | | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| | 0 | 43 | | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| | 0 | 44 | | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // U+00F0..U+00FF |
| | 0 | 45 | | ]; |
| | | 46 | | |
| | | 47 | | #if DEBUG && NET |
| | | 48 | | static JsonWriterHelper() |
| | 0 | 49 | | { |
| | 0 | 50 | | for (int i = 0; i < 128; i++) |
| | 0 | 51 | | { |
| | 0 | 52 | | bool needsEscaping = AllowList[i] == 0; |
| | 0 | 53 | | Debug.Assert(needsEscaping == JavaScriptEncoder.Default.WillEncode(i)); |
| | 0 | 54 | | Debug.Assert(needsEscaping == !s_allowedBytes.Contains((byte)i)); |
| | 0 | 55 | | Debug.Assert(needsEscaping == !s_allowedChars.Contains((char)i)); |
| | 0 | 56 | | } |
| | 0 | 57 | | } |
| | | 58 | | #endif |
| | | 59 | | |
| | | 60 | | #if NET |
| | | 61 | | private const string HexFormatString = "X4"; |
| | | 62 | | #endif |
| | | 63 | | |
| | 0 | 64 | | private static readonly StandardFormat s_hexStandardFormat = new StandardFormat('X', 4); |
| | | 65 | | |
| | 0 | 66 | | private static bool NeedsEscaping(byte value) => AllowList[value] == 0; |
| | | 67 | | |
| | 0 | 68 | | private static bool NeedsEscapingNoBoundsCheck(char value) => AllowList[value] == 0; |
| | | 69 | | |
| | | 70 | | #if NET |
| | | 71 | | // The characters allowed by AllowList, used to vectorize the default (no custom encoder) escaping |
| | | 72 | | // scan directly instead of routing through System.Text.Encodings.Web. |
| | | 73 | | // Validated to match the AllowList and JavaScriptEncoder.Default in the static ctor above. |
| | 0 | 74 | | private static readonly SearchValues<byte> s_allowedBytes = SearchValues.Create( |
| | 0 | 75 | | " !#$%()*,-./0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~"u8); |
| | 0 | 76 | | private static readonly SearchValues<char> s_allowedChars = SearchValues.Create( |
| | 0 | 77 | | " !#$%()*,-./0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~"); |
| | | 78 | | #endif |
| | | 79 | | |
| | | 80 | | public static int NeedsEscaping(ReadOnlySpan<byte> value, JavaScriptEncoder? encoder) |
| | 0 | 81 | | { |
| | | 82 | | #if NET |
| | 0 | 83 | | if (encoder is null || ReferenceEquals(encoder, JavaScriptEncoder.Default)) |
| | 0 | 84 | | { |
| | 0 | 85 | | return value.IndexOfAnyExcept(s_allowedBytes); |
| | | 86 | | } |
| | | 87 | | #endif |
| | | 88 | | |
| | 0 | 89 | | return (encoder ?? JavaScriptEncoder.Default).FindFirstCharacterToEncodeUtf8(value); |
| | 0 | 90 | | } |
| | | 91 | | |
| | | 92 | | public static int NeedsEscaping(ReadOnlySpan<char> value, JavaScriptEncoder? encoder) |
| | 0 | 93 | | { |
| | | 94 | | #if NET |
| | 0 | 95 | | if (encoder is null || ReferenceEquals(encoder, JavaScriptEncoder.Default)) |
| | 0 | 96 | | { |
| | 0 | 97 | | return value.IndexOfAnyExcept(s_allowedChars); |
| | | 98 | | } |
| | | 99 | | #endif |
| | | 100 | | |
| | | 101 | | // Some implementations of JavaScriptEncoder.FindFirstCharacterToEncode may not accept |
| | | 102 | | // null pointers and guard against that. Hence, check up-front to return -1. |
| | 0 | 103 | | if (value.IsEmpty) |
| | 0 | 104 | | { |
| | 0 | 105 | | return -1; |
| | | 106 | | } |
| | | 107 | | |
| | | 108 | | // Unfortunately, there is no public API for FindFirstCharacterToEncode(Span<char>) yet, |
| | | 109 | | // so we have to use the unsafe FindFirstCharacterToEncode(char*, int) instead. |
| | | 110 | | unsafe |
| | 0 | 111 | | { |
| | 0 | 112 | | fixed (char* ptr = value) |
| | 0 | 113 | | { |
| | 0 | 114 | | return (encoder ?? JavaScriptEncoder.Default).FindFirstCharacterToEncode(ptr, value.Length); |
| | | 115 | | } |
| | | 116 | | } |
| | 0 | 117 | | } |
| | | 118 | | |
| | | 119 | | public static int GetMaxEscapedLength(int textLength, int firstIndexToEscape) |
| | 0 | 120 | | { |
| | 0 | 121 | | Debug.Assert(textLength > 0); |
| | 0 | 122 | | Debug.Assert(firstIndexToEscape >= 0 && firstIndexToEscape < textLength); |
| | 0 | 123 | | return firstIndexToEscape + JsonConstants.MaxExpansionFactorWhileEscaping * (textLength - firstIndexToEscape |
| | 0 | 124 | | } |
| | | 125 | | |
| | | 126 | | private static void EscapeString(ReadOnlySpan<byte> value, Span<byte> destination, JavaScriptEncoder encoder, re |
| | 0 | 127 | | { |
| | 0 | 128 | | Debug.Assert(encoder is not null); |
| | | 129 | | |
| | 0 | 130 | | OperationStatus result = encoder.EncodeUtf8(value, destination, out int encoderBytesConsumed, out int encode |
| | | 131 | | |
| | 0 | 132 | | Debug.Assert(result != OperationStatus.DestinationTooSmall); |
| | 0 | 133 | | Debug.Assert(result != OperationStatus.NeedMoreData || !isFinalBlock); |
| | | 134 | | |
| | 0 | 135 | | if (!(result == OperationStatus.Done || (result == OperationStatus.NeedMoreData && !isFinalBlock))) |
| | 0 | 136 | | { |
| | 0 | 137 | | ThrowHelper.ThrowArgumentException_InvalidUTF8(value.Slice(encoderBytesWritten)); |
| | | 138 | | } |
| | | 139 | | |
| | 0 | 140 | | Debug.Assert(encoderBytesConsumed == value.Length || (result == OperationStatus.NeedMoreData && !isFinalBloc |
| | | 141 | | |
| | 0 | 142 | | written += encoderBytesWritten; |
| | 0 | 143 | | consumed += encoderBytesConsumed; |
| | 0 | 144 | | } |
| | | 145 | | |
| | | 146 | | public static void EscapeString(ReadOnlySpan<byte> value, Span<byte> destination, int indexOfFirstByteToEscape, |
| | 0 | 147 | | => EscapeString(value, destination, indexOfFirstByteToEscape, encoder, out _, out written, isFinalBlock: tru |
| | | 148 | | |
| | | 149 | | public static void EscapeString(ReadOnlySpan<byte> value, Span<byte> destination, int indexOfFirstByteToEscape, |
| | 0 | 150 | | { |
| | 0 | 151 | | Debug.Assert(indexOfFirstByteToEscape >= 0 && indexOfFirstByteToEscape < value.Length); |
| | | 152 | | |
| | 0 | 153 | | value.Slice(0, indexOfFirstByteToEscape).CopyTo(destination); |
| | 0 | 154 | | written = indexOfFirstByteToEscape; |
| | 0 | 155 | | consumed = indexOfFirstByteToEscape; |
| | | 156 | | |
| | 0 | 157 | | if (encoder is not null) |
| | 0 | 158 | | { |
| | 0 | 159 | | destination = destination.Slice(indexOfFirstByteToEscape); |
| | 0 | 160 | | value = value.Slice(indexOfFirstByteToEscape); |
| | 0 | 161 | | EscapeString(value, destination, encoder, ref consumed, ref written, isFinalBlock); |
| | 0 | 162 | | } |
| | | 163 | | else |
| | 0 | 164 | | { |
| | | 165 | | // For performance when no encoder is specified, perform escaping here for Ascii and on the |
| | | 166 | | // first occurrence of a non-Ascii character, then call into the default encoder. |
| | 0 | 167 | | while (indexOfFirstByteToEscape < value.Length) |
| | 0 | 168 | | { |
| | 0 | 169 | | byte val = value[indexOfFirstByteToEscape]; |
| | 0 | 170 | | if (IsAsciiValue(val)) |
| | 0 | 171 | | { |
| | 0 | 172 | | if (NeedsEscaping(val)) |
| | 0 | 173 | | { |
| | 0 | 174 | | EscapeNextBytes(val, destination, ref written); |
| | 0 | 175 | | indexOfFirstByteToEscape++; |
| | 0 | 176 | | consumed++; |
| | 0 | 177 | | } |
| | | 178 | | else |
| | 0 | 179 | | { |
| | 0 | 180 | | destination[written] = val; |
| | 0 | 181 | | written++; |
| | 0 | 182 | | indexOfFirstByteToEscape++; |
| | 0 | 183 | | consumed++; |
| | 0 | 184 | | } |
| | 0 | 185 | | } |
| | | 186 | | else |
| | 0 | 187 | | { |
| | | 188 | | // Fall back to default encoder. |
| | 0 | 189 | | destination = destination.Slice(written); |
| | 0 | 190 | | value = value.Slice(indexOfFirstByteToEscape); |
| | 0 | 191 | | EscapeString(value, destination, JavaScriptEncoder.Default, ref consumed, ref written, isFinalBl |
| | 0 | 192 | | break; |
| | | 193 | | } |
| | 0 | 194 | | } |
| | 0 | 195 | | } |
| | 0 | 196 | | } |
| | | 197 | | |
| | | 198 | | private static void EscapeNextBytes(byte value, Span<byte> destination, ref int totalWritten) |
| | 0 | 199 | | { |
| | | 200 | | // Slice the span so the JIT can see that no bounds checks are needed below |
| | 0 | 201 | | destination = destination.Slice(totalWritten, JsonConstants.MaxExpansionFactorWhileEscaping); |
| | 0 | 202 | | int written = 0; |
| | | 203 | | |
| | 0 | 204 | | destination[written++] = (byte)'\\'; |
| | 0 | 205 | | switch (value) |
| | | 206 | | { |
| | | 207 | | case JsonConstants.Quote: |
| | | 208 | | // Optimize for the common quote case. |
| | 0 | 209 | | destination[written++] = (byte)'u'; |
| | 0 | 210 | | destination[written++] = (byte)'0'; |
| | 0 | 211 | | destination[written++] = (byte)'0'; |
| | 0 | 212 | | destination[written++] = (byte)'2'; |
| | 0 | 213 | | destination[written++] = (byte)'2'; |
| | 0 | 214 | | break; |
| | | 215 | | case JsonConstants.LineFeed: |
| | 0 | 216 | | destination[written++] = (byte)'n'; |
| | 0 | 217 | | break; |
| | | 218 | | case JsonConstants.CarriageReturn: |
| | 0 | 219 | | destination[written++] = (byte)'r'; |
| | 0 | 220 | | break; |
| | | 221 | | case JsonConstants.Tab: |
| | 0 | 222 | | destination[written++] = (byte)'t'; |
| | 0 | 223 | | break; |
| | | 224 | | case JsonConstants.BackSlash: |
| | 0 | 225 | | destination[written++] = (byte)'\\'; |
| | 0 | 226 | | break; |
| | | 227 | | case JsonConstants.BackSpace: |
| | 0 | 228 | | destination[written++] = (byte)'b'; |
| | 0 | 229 | | break; |
| | | 230 | | case JsonConstants.FormFeed: |
| | 0 | 231 | | destination[written++] = (byte)'f'; |
| | 0 | 232 | | break; |
| | | 233 | | default: |
| | 0 | 234 | | destination[written++] = (byte)'u'; |
| | | 235 | | |
| | 0 | 236 | | bool result = Utf8Formatter.TryFormat(value, destination.Slice(written), out int bytesWritten, forma |
| | 0 | 237 | | Debug.Assert(result); |
| | 0 | 238 | | Debug.Assert(bytesWritten == 4); |
| | 0 | 239 | | written += bytesWritten; |
| | 0 | 240 | | break; |
| | | 241 | | } |
| | | 242 | | |
| | 0 | 243 | | totalWritten += written; |
| | 0 | 244 | | } |
| | | 245 | | |
| | 0 | 246 | | private static bool IsAsciiValue(byte value) => value <= LastAsciiCharacter; |
| | | 247 | | |
| | 0 | 248 | | private static bool IsAsciiValue(char value) => value <= LastAsciiCharacter; |
| | | 249 | | |
| | | 250 | | private static void EscapeString(ReadOnlySpan<char> value, Span<char> destination, JavaScriptEncoder encoder, re |
| | 0 | 251 | | { |
| | 0 | 252 | | Debug.Assert(encoder is not null); |
| | | 253 | | |
| | 0 | 254 | | OperationStatus result = encoder.Encode(value, destination, out int encoderBytesConsumed, out int encoderCha |
| | | 255 | | |
| | 0 | 256 | | Debug.Assert(result != OperationStatus.DestinationTooSmall); |
| | 0 | 257 | | Debug.Assert(result != OperationStatus.NeedMoreData || !isFinalBlock); |
| | | 258 | | |
| | 0 | 259 | | if (!(result == OperationStatus.Done || (result == OperationStatus.NeedMoreData && !isFinalBlock))) |
| | 0 | 260 | | { |
| | 0 | 261 | | ThrowHelper.ThrowArgumentException_InvalidUTF16(value[encoderCharsWritten]); |
| | | 262 | | } |
| | | 263 | | |
| | 0 | 264 | | Debug.Assert(encoderBytesConsumed == value.Length || (result == OperationStatus.NeedMoreData && !isFinalBloc |
| | | 265 | | |
| | 0 | 266 | | written += encoderCharsWritten; |
| | 0 | 267 | | consumed += encoderBytesConsumed; |
| | 0 | 268 | | } |
| | | 269 | | |
| | | 270 | | public static void EscapeString(ReadOnlySpan<char> value, Span<char> destination, int indexOfFirstByteToEscape, |
| | 0 | 271 | | => EscapeString(value, destination, indexOfFirstByteToEscape, encoder, out _, out written, isFinalBlock: tru |
| | | 272 | | |
| | | 273 | | public static void EscapeString(ReadOnlySpan<char> value, Span<char> destination, int indexOfFirstByteToEscape, |
| | 0 | 274 | | { |
| | 0 | 275 | | Debug.Assert(indexOfFirstByteToEscape >= 0 && indexOfFirstByteToEscape < value.Length); |
| | | 276 | | |
| | 0 | 277 | | value.Slice(0, indexOfFirstByteToEscape).CopyTo(destination); |
| | 0 | 278 | | written = indexOfFirstByteToEscape; |
| | 0 | 279 | | consumed = indexOfFirstByteToEscape; |
| | | 280 | | |
| | 0 | 281 | | if (encoder is not null) |
| | 0 | 282 | | { |
| | 0 | 283 | | destination = destination.Slice(indexOfFirstByteToEscape); |
| | 0 | 284 | | value = value.Slice(indexOfFirstByteToEscape); |
| | 0 | 285 | | EscapeString(value, destination, encoder, ref consumed, ref written, isFinalBlock); |
| | 0 | 286 | | } |
| | | 287 | | else |
| | 0 | 288 | | { |
| | | 289 | | // For performance when no encoder is specified, perform escaping here for Ascii and on the |
| | | 290 | | // first occurrence of a non-Ascii character, then call into the default encoder. |
| | 0 | 291 | | while (indexOfFirstByteToEscape < value.Length) |
| | 0 | 292 | | { |
| | 0 | 293 | | char val = value[indexOfFirstByteToEscape]; |
| | 0 | 294 | | if (IsAsciiValue(val)) |
| | 0 | 295 | | { |
| | 0 | 296 | | if (NeedsEscapingNoBoundsCheck(val)) |
| | 0 | 297 | | { |
| | 0 | 298 | | EscapeNextChars(val, destination, ref written); |
| | 0 | 299 | | indexOfFirstByteToEscape++; |
| | 0 | 300 | | consumed++; |
| | 0 | 301 | | } |
| | | 302 | | else |
| | 0 | 303 | | { |
| | 0 | 304 | | destination[written] = val; |
| | 0 | 305 | | written++; |
| | 0 | 306 | | indexOfFirstByteToEscape++; |
| | 0 | 307 | | consumed++; |
| | 0 | 308 | | } |
| | 0 | 309 | | } |
| | | 310 | | else |
| | 0 | 311 | | { |
| | | 312 | | // Fall back to default encoder. |
| | 0 | 313 | | destination = destination.Slice(written); |
| | 0 | 314 | | value = value.Slice(indexOfFirstByteToEscape); |
| | 0 | 315 | | EscapeString(value, destination, JavaScriptEncoder.Default, ref consumed, ref written, isFinalBl |
| | 0 | 316 | | break; |
| | | 317 | | } |
| | 0 | 318 | | } |
| | 0 | 319 | | } |
| | 0 | 320 | | } |
| | | 321 | | |
| | | 322 | | private static void EscapeNextChars(char value, Span<char> destination, ref int totalWritten) |
| | 0 | 323 | | { |
| | 0 | 324 | | Debug.Assert(IsAsciiValue(value)); |
| | | 325 | | |
| | | 326 | | // Slice the span so the JIT can see that no bounds checks are needed below |
| | 0 | 327 | | destination = destination.Slice(totalWritten, JsonConstants.MaxExpansionFactorWhileEscaping); |
| | 0 | 328 | | int written = 0; |
| | | 329 | | |
| | 0 | 330 | | destination[written++] = '\\'; |
| | 0 | 331 | | switch ((byte)value) |
| | | 332 | | { |
| | | 333 | | case JsonConstants.Quote: |
| | | 334 | | // Optimize for the common quote case. |
| | 0 | 335 | | destination[written++] = 'u'; |
| | 0 | 336 | | destination[written++] = '0'; |
| | 0 | 337 | | destination[written++] = '0'; |
| | 0 | 338 | | destination[written++] = '2'; |
| | 0 | 339 | | destination[written++] = '2'; |
| | 0 | 340 | | break; |
| | | 341 | | case JsonConstants.LineFeed: |
| | 0 | 342 | | destination[written++] = 'n'; |
| | 0 | 343 | | break; |
| | | 344 | | case JsonConstants.CarriageReturn: |
| | 0 | 345 | | destination[written++] = 'r'; |
| | 0 | 346 | | break; |
| | | 347 | | case JsonConstants.Tab: |
| | 0 | 348 | | destination[written++] = 't'; |
| | 0 | 349 | | break; |
| | | 350 | | case JsonConstants.BackSlash: |
| | 0 | 351 | | destination[written++] = '\\'; |
| | 0 | 352 | | break; |
| | | 353 | | case JsonConstants.BackSpace: |
| | 0 | 354 | | destination[written++] = 'b'; |
| | 0 | 355 | | break; |
| | | 356 | | case JsonConstants.FormFeed: |
| | 0 | 357 | | destination[written++] = 'f'; |
| | 0 | 358 | | break; |
| | | 359 | | default: |
| | 0 | 360 | | destination[written++] = 'u'; |
| | | 361 | | #if NET |
| | 0 | 362 | | int intChar = value; |
| | 0 | 363 | | intChar.TryFormat(destination.Slice(written), out int charsWritten, HexFormatString); |
| | 0 | 364 | | Debug.Assert(charsWritten == 4); |
| | 0 | 365 | | written += charsWritten; |
| | | 366 | | #else |
| | | 367 | | written = WriteHex(value, destination, written); |
| | | 368 | | #endif |
| | 0 | 369 | | break; |
| | | 370 | | } |
| | | 371 | | |
| | 0 | 372 | | totalWritten += written; |
| | 0 | 373 | | } |
| | | 374 | | |
| | | 375 | | #if !NET |
| | | 376 | | private static int WriteHex(int value, Span<char> destination, int written) |
| | | 377 | | { |
| | | 378 | | destination[written++] = HexConverter.ToCharUpper(value >> 12); |
| | | 379 | | destination[written++] = HexConverter.ToCharUpper(value >> 8); |
| | | 380 | | destination[written++] = HexConverter.ToCharUpper(value >> 4); |
| | | 381 | | destination[written++] = HexConverter.ToCharUpper(value); |
| | | 382 | | return written; |
| | | 383 | | } |
| | | 384 | | #endif |
| | | 385 | | } |
| | | 386 | | } |
| | | 387 | | |