Skip to content

Commit

Permalink
detect duplicate colon in BaseProtocolHeader
Browse files Browse the repository at this point in the history
  • Loading branch information
Techatrix committed Nov 7, 2024
1 parent 6b34887 commit c1cf5ca
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lsp.zig
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,7 @@ pub const BaseProtocolHeader = struct {
':' => {
// The ": " is not being added to the buffer here!
if (try reader.readByte() != ' ') return error.InvalidHeaderField;
if (maybe_colon_index != null) return error.InvalidHeaderField; // duplicate ':'
maybe_colon_index = buffer_index;
},
else => {
Expand Down Expand Up @@ -915,6 +916,7 @@ pub const BaseProtocolHeader = struct {
try expectParseError("contentLength: 32\r\n\r\n", error.MissingContentLength);
try expectParseError("content-length: abababababab\r\n\r\n", error.InvalidContentLength);
try expectParseError("content-length: 9999999999999999999999999999999999\r\n\r\n", error.OversizedMessage);
try expectParseError("content-length: : 32\r\n\r\n", error.InvalidHeaderField);

try expectParse("content-length: 32\r\n\r\n", .{ .content_length = 32 });
try expectParse("Content-Length: 32\r\n\r\n", .{ .content_length = 32 });
Expand Down

0 comments on commit c1cf5ca

Please sign in to comment.