mirror of
https://github.com/bitwarden/server
synced 2025-12-10 13:23:27 +00:00
Changed all C# control flow block statements to include space between keyword and open paren
This commit is contained in:
@@ -20,36 +20,36 @@ namespace Bit.Api.Utilities
|
||||
var reader = new MultipartReader(boundary, request.Body);
|
||||
|
||||
var firstSection = await reader.ReadNextSectionAsync();
|
||||
if(firstSection != null)
|
||||
if (firstSection != null)
|
||||
{
|
||||
if(ContentDispositionHeaderValue.TryParse(firstSection.ContentDisposition, out var firstContent))
|
||||
if (ContentDispositionHeaderValue.TryParse(firstSection.ContentDisposition, out var firstContent))
|
||||
{
|
||||
if(HasFileContentDisposition(firstContent))
|
||||
if (HasFileContentDisposition(firstContent))
|
||||
{
|
||||
// Old style with just data
|
||||
var fileName = HeaderUtilities.RemoveQuotes(firstContent.FileName).ToString();
|
||||
using(firstSection.Body)
|
||||
using (firstSection.Body)
|
||||
{
|
||||
await callback(firstSection.Body, fileName, null);
|
||||
}
|
||||
}
|
||||
else if(HasKeyDisposition(firstContent))
|
||||
else if (HasKeyDisposition(firstContent))
|
||||
{
|
||||
// New style with key, then data
|
||||
string key = null;
|
||||
using(var sr = new StreamReader(firstSection.Body))
|
||||
using (var sr = new StreamReader(firstSection.Body))
|
||||
{
|
||||
key = await sr.ReadToEndAsync();
|
||||
}
|
||||
|
||||
var secondSection = await reader.ReadNextSectionAsync();
|
||||
if(secondSection != null)
|
||||
if (secondSection != null)
|
||||
{
|
||||
if(ContentDispositionHeaderValue.TryParse(secondSection.ContentDisposition,
|
||||
if (ContentDispositionHeaderValue.TryParse(secondSection.ContentDisposition,
|
||||
out var secondContent) && HasFileContentDisposition(secondContent))
|
||||
{
|
||||
var fileName = HeaderUtilities.RemoveQuotes(secondContent.FileName).ToString();
|
||||
using(secondSection.Body)
|
||||
using (secondSection.Body)
|
||||
{
|
||||
await callback(secondSection.Body, fileName, key);
|
||||
}
|
||||
@@ -67,12 +67,12 @@ namespace Bit.Api.Utilities
|
||||
private static string GetBoundary(MediaTypeHeaderValue contentType, int lengthLimit)
|
||||
{
|
||||
var boundary = HeaderUtilities.RemoveQuotes(contentType.Boundary);
|
||||
if(StringSegment.IsNullOrEmpty(boundary))
|
||||
if (StringSegment.IsNullOrEmpty(boundary))
|
||||
{
|
||||
throw new InvalidDataException("Missing content-type boundary.");
|
||||
}
|
||||
|
||||
if(boundary.Length > lengthLimit)
|
||||
if (boundary.Length > lengthLimit)
|
||||
{
|
||||
throw new InvalidDataException($"Multipart boundary length limit {lengthLimit} exceeded.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user