fix(openapi_fdw): respect quoted strings and escapes in Link header - #626
Open
Vishv07 wants to merge 1 commit into
Open
fix(openapi_fdw): respect quoted strings and escapes in Link header#626Vishv07 wants to merge 1 commit into
Vishv07 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes an RFC 8288 parameter parsing bug in
openapi_fdw/src/response.rswhere a semicolon inside a quoted parameter value (such astitle="item;rel=next") was treated as a top-level parameter delimiter, causinghas_rel_next()to falsely identify the link entry as havingrel="next".Problem
In
split_link_entries(), entries are split on commas while carefully respecting quoted strings and RFC 7230 backslash escapes (\").However,
has_rel_next()previously split parameters using a plainparams.split(';'). When a quoted parameter contained a semicolon and the substringrel=next(e.g.<https://api.example.com/items>; title="page;rel=next"; rel="last"):split(';')split the parameter into fragmentstitle="pageandrel=next".split_once('=')matchedname="rel", andtrim_matches('"')producedvalue="next".has_rel_next()returnedtrue, incorrectly treating arel="last"URL as the next pagination page.Solution
split_link_params(), which splits parameter lists on top-level semicolons while honoring quoted strings and RFC 7230quoted-pairbackslash escapes(mirroring the entry splitting behavior in
split_link_entries()).has_rel_next()to iterate oversplit_link_params(params)instead ofparams.split(';').response_tests.rscovering:title="a;rel=next"; rel="last"returningNone).rel="next"parameters present.title="item \"foo;bar\""; rel="next").Verification
mainand passes with this fix.make checksuite inwasm-wrappers/fdw/openapi_fdwpasses cleanly:cargo fmtcleancargo clippy --all --tests --no-depswith 0 warningscargo component build --release --target wasm32-unknown-unknownsucceeds