-
Notifications
You must be signed in to change notification settings - Fork 412
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
fix: Ignore everything after closing boundary when parsing multi form data #2862
fix: Ignore everything after closing boundary when parsing multi form data #2862
Conversation
thx @seakayone for pushing this one. |
This fix is not yet complete and more of a rough first shot. It currently has a couple of "problems":
I will not be able to do much the next couple of days and will progress on this in June hopefully. |
can we overcome first issue by having size counter in FormStateBuffer instead? |
@seakayone if you want to have the bounty, you have to add |
💵 To receive payouts, sign up on Algora, link your Github account and connect with Stripe/Alipay. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some minor comments from my side, otherwise looks good to me :)
zio-http/shared/src/main/scala/zio/http/internal/FormState.scala
Outdated
Show resolved
Hide resolved
zio-http/shared/src/main/scala/zio/http/internal/FormState.scala
Outdated
Show resolved
Hide resolved
zio-http/shared/src/main/scala/zio/http/internal/FormState.scala
Outdated
Show resolved
Hide resolved
zio-http/shared/src/main/scala/zio/http/internal/FormState.scala
Outdated
Show resolved
Hide resolved
zio-http/shared/src/main/scala/zio/http/internal/FormState.scala
Outdated
Show resolved
Hide resolved
zio-http/shared/src/main/scala/zio/http/internal/FormState.scala
Outdated
Show resolved
Hide resolved
Co-authored-by: kyri-petrou <[email protected]>
… Array[Boolean](closingBoundaryBytesSize)
Co-authored-by: kyri-petrou <[email protected]>
Thank you @kyri-petrou I have addressed all you remarks, tests are passing. Please have another look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I didn't pick this up in the last review round. I might be missing something but I think we can simplify the logic massively
private val buffer: ChunkBuilder[Byte] = new ChunkBuilder.Byte | ||
private var bufferSize: Int = 0 | ||
private val closingBoundaryBytesSize = boundary.closingBoundaryBytes.size | ||
private var boundaryMatches: Array[Boolean] = new Array[Boolean](closingBoundaryBytesSize) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is something here that I don't understand / failing to see. What is the reason for using an array? Can't this be just a boolean and then L62-68 become this?
boundaryMatches &&= posInLine < closingBoundaryBytesSize && boundary.closingBoundaryBytes(posInLine) == byte
val boundaryDetected = boundaryMatches && posInLine == closingBoundaryBytesSize - 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonderful, you are right we do not need to remember all checked bytes this way.
That works => f1f33ba
Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tbh no idea why i thought we need an array 🙈 so much better without - nice find @kyri-petrou 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to approve this PR! However, I think you still need an approval from a code owner to get it merged
Resolves: #2411
Enables: softwaremill/tapir#3690
Based on an idea by @fliiiix. Co-authored with @fliiiix and @grigala during a Hackergarten session.
/claim #2411
/split @fliiiix
/split @grigala