Skip to content

Commit

Permalink
check for buffer mismatch every boundary parse cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
tanner0101 committed Apr 3, 2017
1 parent 9a7f9b2 commit 10acbcf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions Sources/Multipart/BoundaryParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ final class BoundaryParser {
let match = [.hyphen, .hyphen] + boundary

if
(buffer.count <= 1 && byte == .hyphen) ||
(buffer.count > 1 && buffer.count < match.count)
buffer.count < match.count && match[buffer.count] == byte
{
state = .parsing(buffer: buffer + [byte], trailingHyphenCount: trailingHyphenCount)
break main
Expand Down
2 changes: 1 addition & 1 deletion Tests/FormDataTests/ParserTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,6 @@ class ParserTests: XCTestCase {
try parser.multipart.parse(message)

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

0 comments on commit 10acbcf

Please sign in to comment.