Skip to content

Commit

Permalink
check for buffer mismatch every boundary parse cycle (v1)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanner0101 authored and vzsg committed Apr 5, 2017
1 parent 9dcfd47 commit e13f33a
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 @@ -47,8 +47,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 @@ -137,7 +137,7 @@ class ParserTests: XCTestCase {
try parser.multipart.parse(message)

for i in 1...5 {
XCTAssertEqual(fields["field\(i)"]?.part.body.makeString(), "The Quick Brown Fox Jumps Over The Lazy Dog", "Field 'field\(i)' was parsed incorrectly!")
XCTAssertEqual(fields["field\(i)"]?.part.body.string, "The Quick Brown Fox Jumps Over The Lazy Dog", "Field 'field\(i)' was parsed incorrectly!")
}
}

Expand Down

0 comments on commit e13f33a

Please sign in to comment.