Skip to content

Commit

Permalink
Stricter request/response parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
osipxd committed Feb 13, 2025
1 parent 0fd5aed commit c8e3aaa
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright 2014-2021 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
* Copyright 2014-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

package io.ktor.http.cio

Expand Down Expand Up @@ -31,7 +31,7 @@ public suspend fun parseRequest(input: ByteReadChannel): Request? {

try {
while (true) {
if (!input.readUTF8LineTo(builder, HTTP_LINE_LIMIT)) return null
if (!input.readUTF8LineTo(builder, HTTP_LINE_LIMIT, LineEndingMode.HttpLineEndings)) return null
range.end = builder.length
if (range.start == range.end) continue

Expand Down Expand Up @@ -66,7 +66,7 @@ public suspend fun parseResponse(input: ByteReadChannel): Response? {
val range = MutableRange(0, 0)

try {
if (!input.readUTF8LineTo(builder, HTTP_LINE_LIMIT)) return null
if (!input.readUTF8LineTo(builder, HTTP_LINE_LIMIT, LineEndingMode.HttpLineEndings)) return null
range.end = builder.length

val version = parseVersion(builder, range)
Expand Down Expand Up @@ -106,7 +106,7 @@ internal suspend fun parseHeaders(

try {
while (true) {
if (!input.readUTF8LineTo(builder, HTTP_LINE_LIMIT)) {
if (!input.readUTF8LineTo(builder, HTTP_LINE_LIMIT, LineEndingMode.HttpLineEndings)) {
headers.release()
return null
}
Expand Down

0 comments on commit c8e3aaa

Please sign in to comment.