Skip to content

Remove redundant comment about query param validation #497

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

Merged
merged 2 commits into from
Mar 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions internal/nginx/modules/src/httpmatches.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,13 @@ function headersMatch(requestHeaders, headers) {
function paramsMatch(requestParams, params) {
for (let i = 0; i < params.length; i++) {
let p = params[i];
// We store query parameter matches as strings with the format "key=value"; however, there may be more than one instance of "=" in the string.
// We store query parameter matches as strings with the format "key=value"; however, there may be more than one
// instance of "=" in the string.
// To recover the key and value, we need to find the first occurrence of "=" in the string.
const idx = params[i].indexOf('=');
// Check for an improperly constructed query parameter match. There are three possible error cases:
// (1) if the index is -1, then there are no "=" in the string (e.g. "keyvalue")
// (2) if the index is 0, then there is no value in the string (e.g. "key=").
// NOTE: While query parameter values are permitted to be empty, the Gateway API Spec forces the value to be a non-empty string.
// https://github.com/kubernetes-sigs/gateway-api/blob/e9e04e498c566021c9d30ce4dbe0863894c7d7e1/apis/v1beta1/httproute_types.go#L419
// (3) if the index is equal to length -1, then there is no key in the string (e.g. "=value").
if (idx === -1 || (idx === 0) | (idx === p.length - 1)) {
throw Error(`invalid query parameter: ${p}`);
Expand Down