just noticed a bug in zig’s 0.13.0 std.http module. std.http.Server in finishReceivingHead() (I AM MATURE) fucks up and while parsing does the following:
imagine we have a request:
GET /index.html HTTP/1.1\n\n where \n\n is line ending and head ending.
the std.http.Server.Request.Head.parse() fucks the parsing part up. first it looks up the index of a first space: std.mem.indexOf(...), making a slice of the read buffer, which gives us a slice = GET. then, it goes ahead and parses the target, in this case /index.html. but then the most interesting thing happens.
in the code the parse() function gets the index of the last space std.mem.lastIndexOf(...), makes it a version_start, and slices the read buffer to the end of the line. how? well, it only uses the atrocious windows line endings: ‘\r\n’. of course, it’s not a bug if it follows the spec, but fuck me, i wasted too much time debugging this shit. is it really that personal to add support for linux line endings? god fucking damn it.