Skip to content

Commit c1cf5ca

Browse files
committed
detect duplicate colon in BaseProtocolHeader
1 parent 6b34887 commit c1cf5ca

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/lsp.zig

+2
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,7 @@ pub const BaseProtocolHeader = struct {
872872
':' => {
873873
// The ": " is not being added to the buffer here!
874874
if (try reader.readByte() != ' ') return error.InvalidHeaderField;
875+
if (maybe_colon_index != null) return error.InvalidHeaderField; // duplicate ':'
875876
maybe_colon_index = buffer_index;
876877
},
877878
else => {
@@ -915,6 +916,7 @@ pub const BaseProtocolHeader = struct {
915916
try expectParseError("contentLength: 32\r\n\r\n", error.MissingContentLength);
916917
try expectParseError("content-length: abababababab\r\n\r\n", error.InvalidContentLength);
917918
try expectParseError("content-length: 9999999999999999999999999999999999\r\n\r\n", error.OversizedMessage);
919+
try expectParseError("content-length: : 32\r\n\r\n", error.InvalidHeaderField);
918920

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

0 commit comments

Comments
 (0)