Skip to content

Commit 10acbcf

Browse files
committed
check for buffer mismatch every boundary parse cycle
1 parent 9a7f9b2 commit 10acbcf

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

Sources/Multipart/BoundaryParser.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ final class BoundaryParser {
4343
let match = [.hyphen, .hyphen] + boundary
4444

4545
if
46-
(buffer.count <= 1 && byte == .hyphen) ||
47-
(buffer.count > 1 && buffer.count < match.count)
46+
buffer.count < match.count && match[buffer.count] == byte
4847
{
4948
state = .parsing(buffer: buffer + [byte], trailingHyphenCount: trailingHyphenCount)
5049
break main

Tests/FormDataTests/ParserTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,6 @@ class ParserTests: XCTestCase {
163163
try parser.multipart.parse(message)
164164

165165
XCTAssertEqual(fields["file"]?.filename, "test.txt")
166-
XCTAssertEqual("---this is a test", fields["file"]?.part.body.string)
166+
XCTAssertEqual("---this is a test", fields["file"]?.part.body.makeString())
167167
}
168168
}

0 commit comments

Comments
 (0)