Skip to content

Commit bbd739c

Browse files
Fix invalid catch block in StringUtilities (#49082)
1 parent 1e86b6c commit bbd739c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Shared/ServerInfrastructure/StringUtilities.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,9 +683,13 @@ private static bool IsValidHeaderString(string value)
683683
new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true).GetByteCount(value);
684684
return !value.Contains('\0');
685685
}
686-
catch (DecoderFallbackException)
686+
catch (ArgumentOutOfRangeException)
687687
{
688-
return false;
688+
return false; // 'value' too large to compute a UTF-8 byte count
689+
}
690+
catch (EncoderFallbackException)
691+
{
692+
return false; // 'value' cannot be converted losslessly to UTF-8
689693
}
690694
}
691695

0 commit comments

Comments
 (0)