Skip to content

Commit

Permalink
deny 0x number
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Jan 19, 2024
1 parent 2902990 commit d1b0152
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion kong/db/schema/entities/routes.lua
Expand Up @@ -13,7 +13,7 @@ do
local transform_expression = require("kong.router.expressions").transform_expression

local HTTP_PATH_SEGMENTS_PREFIX = "http.path.segments."
local HTTP_PATH_SEGMENTS_SUFFIX_REG = [[^(\d+)(_(\d+))?$]]
local HTTP_PATH_SEGMENTS_SUFFIX_REG = [[^(0|[1-9]\d*)(_(0|[1-9]\d*))?$]]

-- works with both `traditional_compatiable` and `expressions` routes`
validate_route = function(entity)
Expand Down
5 changes: 4 additions & 1 deletion spec/01-unit/01-db/01-schema/06-routes_spec.lua
Expand Up @@ -1567,7 +1567,7 @@ describe("routes schema (flavor = expressions)", function()
id = a_valid_uuid,
name = "my_route",
protocols = { "grpcs" },
expression = [[http.path.segments.0 == "foo" && http.path.segments.1 ^= "bar" && http.path.segments.2_3 ~ r#"x/y"#]],
expression = [[http.path.segments.0 == "foo" && http.path.segments.1 ^= "bar" && http.path.segments.20_30 ~ r#"x/y"#]],
priority = 100,
service = { id = another_uuid },
}
Expand All @@ -1593,6 +1593,9 @@ describe("routes schema (flavor = expressions)", function()
[[http.path.segments._1 == "foo"]],
[[http.path.segments.2_1 == "foo"]],
[[http.path.segments.1_1 == "foo"]],
[[http.path.segments.01_2 == "foo"]],
[[http.path.segments.001_2 == "foo"]],
[[http.path.segments.1_03 == "foo"]],
}

for _, exp in ipairs(wrong_expressions) do
Expand Down

0 comments on commit d1b0152

Please sign in to comment.