-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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(core): validation against header regex match #13290
Conversation
ef8b4c2
to
f5accc1
Compare
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.
The header.value
will be treated as a regex if and only if there is only one value, but the current impl doesn't fit it.
98360be
to
e631d02
Compare
e631d02
to
907368f
Compare
907368f
to
2fb012c
Compare
e62b197
to
b00ac60
Compare
-- the value will be interpreted as a regex by the router; but is it a | ||
-- valid one? Let's dry-run it with the same options as our router. | ||
local _, _, err = ngx.re.find("", regex, "aj") | ||
local _, _, err = ngx.re.find("", pattern, "a") |
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.
Add a comment for removing the option j
.
if not is_regex_pattern(pattern) then | ||
local function validate_header_regex_or_plain_pattern(patterns) | ||
-- when there's only 1 pattern and it starts with "~*", it's a regex pattern | ||
if #patterns ~= 1 or patterns[1]:sub(1, 2) ~= "~*" then |
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.
The NOT condition is hard to understand, could we rewrite it like
if #patterns == 1 and patterns[1]:sub(1, 2) == "~*" then
return is_valid_regex_pattern(patterns[1]:sub(3))
end
return true
3339d10
to
619feef
Compare
should we close it? |
Let's close this |
Summary
The regex pattern for header should starts with "~*" instead of "~"
Checklist
changelog/unreleased/kong
orskip-changelog
label added on PR if changelog is unnecessary. README.mdIssue reference
fixup #12365
fix KAG-4788