Skip to content

Commit ee5e5cf

Browse files
committed
Soundness
1 parent 854653d commit ee5e5cf

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

Sources/NIOIMAPCore/Parser/Grammar/GrammarParser.swift

+18-18
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ extension GrammarParser {
650650
}
651651

652652
return try withoutActuallyEscaping(parseLastCommandSet_set) { (parseLastCommandSet_set) in
653-
return try self.oneOf(
653+
try self.oneOf(
654654
parseLastCommandSet_lastCommand,
655655
parseLastCommandSet_set,
656656
buffer: &buffer,
@@ -1330,7 +1330,7 @@ extension GrammarParser {
13301330
try self.fixedString("RFC822", buffer: &buffer, tracker: tracker)
13311331
return .rfc822
13321332
}
1333-
1333+
13341334
return try self.composite(buffer: &buffer, tracker: tracker) { (buffer, tracker) -> Media.Message in
13351335
try self.fixedString("\"MESSAGE\" \"", buffer: &buffer, tracker: tracker)
13361336
let message = try parseMediaMessage_rfc(buffer: &buffer, tracker: tracker)
@@ -2425,8 +2425,8 @@ extension GrammarParser {
24252425
{
24262426
var sources = [try parseFilterMailboxes(buffer: &buffer, tracker: tracker)]
24272427
while let anotherSource = try self.optional(buffer: &buffer,
2428-
tracker: tracker,
2429-
parser: parseExtendedSearchSourceOptions_spaceFilter)
2428+
tracker: tracker,
2429+
parser: parseExtendedSearchSourceOptions_spaceFilter)
24302430
{
24312431
sources.append(anotherSource)
24322432
}
@@ -2446,8 +2446,8 @@ extension GrammarParser {
24462446
try self.fixedString("IN (", buffer: &buffer, tracker: tracker)
24472447
let sourceMbox = try parseExtendedSearchSourceOptions_sourceMBox(buffer: &buffer, tracker: tracker)
24482448
let scopeOptions = try self.optional(buffer: &buffer,
2449-
tracker: tracker,
2450-
parser: parseExtendedSearchSourceOptions_scopeOptions)
2449+
tracker: tracker,
2450+
parser: parseExtendedSearchSourceOptions_scopeOptions)
24512451
try self.fixedString(")", buffer: &buffer, tracker: tracker)
24522452
if let result = ExtendedSearchSourceOptions(sourceMailbox: sourceMbox, scopeOptions: scopeOptions) {
24532453
return result
@@ -2473,11 +2473,11 @@ extension GrammarParser {
24732473
}
24742474

24752475
let sourceOptions = try self.optional(buffer: &buffer,
2476-
tracker: tracker,
2477-
parser: parseExtendedSearchOptions_sourceOptions)
2476+
tracker: tracker,
2477+
parser: parseExtendedSearchOptions_sourceOptions)
24782478
let returnOpts = try self.optional(buffer: &buffer,
2479-
tracker: tracker,
2480-
parser: self.parseSearchReturnOptions) ?? []
2479+
tracker: tracker,
2480+
parser: self.parseSearchReturnOptions) ?? []
24812481
try self.spaces(buffer: &buffer, tracker: tracker)
24822482
let (charset, program) = try parseSearchProgram(buffer: &buffer, tracker: tracker)
24832483
return ExtendedSearchOptions(key: program, charset: charset, returnOptions: returnOpts, sourceOptions: sourceOptions)
@@ -2527,8 +2527,8 @@ struct StackTracker {
25272527
}
25282528

25292529
// MARK: - ParserLibrary shortcuts
2530-
extension GrammarParser {
25312530

2531+
extension GrammarParser {
25322532
static func oneOrMoreCharacters(buffer: inout ParseBuffer, tracker: StackTracker, where: ((UInt8) -> Bool)) throws -> ByteBuffer {
25332533
try ParserLibrary.parseOneOrMoreCharacters(buffer: &buffer, tracker: tracker, where: `where`)
25342534
}
@@ -2582,18 +2582,18 @@ extension GrammarParser {
25822582
}
25832583

25842584
static func oneOf<T>(_ parser1: SubParser<T>,
2585-
_ parser2: SubParser<T>,
2586-
buffer: inout ParseBuffer,
2587-
tracker: StackTracker, file: String = (#file), line: Int = #line) throws -> T
2585+
_ parser2: SubParser<T>,
2586+
buffer: inout ParseBuffer,
2587+
tracker: StackTracker, file: String = (#file), line: Int = #line) throws -> T
25882588
{
25892589
try ParserLibrary.oneOf2(parser1, parser2, buffer: &buffer, tracker: tracker)
25902590
}
25912591

25922592
static func oneOf<T>(_ parser1: SubParser<T>,
2593-
_ parser2: SubParser<T>,
2594-
_ parser3: SubParser<T>,
2595-
buffer: inout ParseBuffer,
2596-
tracker: StackTracker, file: String = (#file), line: Int = #line) throws -> T
2593+
_ parser2: SubParser<T>,
2594+
_ parser3: SubParser<T>,
2595+
buffer: inout ParseBuffer,
2596+
tracker: StackTracker, file: String = (#file), line: Int = #line) throws -> T
25972597
{
25982598
try ParserLibrary.oneOf3(parser1, parser2, parser3, buffer: &buffer, tracker: tracker)
25992599
}

Sources/NIOIMAPCore/Parser/ParserLibrary.swift

-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ public struct TooMuchRecursion: Error {
7070
}
7171

7272
extension ParserLibrary {
73-
7473
static func parseZeroOrMoreCharacters(buffer: inout ParseBuffer, tracker: StackTracker, where: ((UInt8) -> Bool)) throws -> ByteBuffer {
7574
try ParserLibrary.composite(buffer: &buffer, tracker: tracker) { buffer, _ in
7675
let maybeFirstBad = buffer.bytes.readableBytesView.firstIndex { char in

0 commit comments

Comments
 (0)