Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KTOR-7201 Fix data truncated in receiveParameters and receiveMultipart #4116

Merged
merged 3 commits into from
Jul 22, 2024

Conversation

e5l
Copy link
Member

@e5l e5l commented Jul 11, 2024

Fix KTOR-7201 Data truncated in receiveParameters and receiveMultipart

@e5l e5l requested a review from bjhham July 11, 2024 14:43
@e5l e5l self-assigned this Jul 11, 2024
@e5l e5l force-pushed the e5l/multipart-field-limit branch 2 times, most recently from be1c844 to 0b9bafa Compare July 17, 2024 08:18
Comment on lines 74 to 82
if (!body.isClosedForRead) {
body.awaitContent()
if (!body.isClosedForRead) {
packet.release()
val cause = IllegalStateException("Form field size limit exceeded: $formFieldLimit")
body.cancel(cause)
throw cause
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could introduce an extension method here like body.assertClosedForRead { packet.release(); "Form field size limit exceeded: $formFieldLimit" } to make it a little more declarative and reuseable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make suspend fun ByteReadChannel.exhausted(): Boolean instead

@e5l e5l force-pushed the e5l/multipart-field-limit branch from 0b9bafa to c0e9aa6 Compare July 18, 2024 11:13
@e5l e5l force-pushed the e5l/multipart-field-limit branch from 375f9ee to b9d48ba Compare July 19, 2024 13:48
@e5l e5l force-pushed the e5l/multipart-field-limit branch from b9d48ba to 08bfacf Compare July 22, 2024 07:35
@e5l e5l merged commit 66568cd into main Jul 22, 2024
2 checks passed
@e5l e5l deleted the e5l/multipart-field-limit branch July 22, 2024 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants