Skip to content

Commit

Permalink
update strip
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed May 29, 2024
1 parent d407cdc commit b6ac910
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion kong/plugins/ai-proxy/handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local cjson = require("cjson.safe")
local kong_utils = require("kong.tools.gzip")
local kong_meta = require("kong.meta")
local buffer = require "string.buffer"
local strip = require("kong.tools.utils").strip
local strip = require("kong.tools.string").strip
--


Expand Down
2 changes: 1 addition & 1 deletion kong/plugins/bot-detection/handler.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local rules = require "kong.plugins.bot-detection.rules"
local strip = require("kong.tools.utils").strip
local strip = require("kong.tools.string").strip
local lrucache = require "resty.lrucache"
local kong_meta = require "kong.meta"

Expand Down
26 changes: 13 additions & 13 deletions kong/plugins/oauth2/secret.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local utils = require "kong.tools.utils"
local kong_string = require "kong.tools.string"


local type = type
Expand Down Expand Up @@ -34,20 +34,20 @@ local ENABLED_ALGORITHMS = {


local function infer(value)
value = utils.strip(value)
value = kong_string.strip(value)
return tonumber(value, 10) or value
end


local function parse_phc(phc)
local parts = utils.split(phc, "$")
local parts = kong_string.split(phc, "$")
local count = #parts
if count < 2 or count > 5 then
return nil, "invalid phc string format"
end

local id = parts[2]
local id_parts = utils.split(id, "-")
local id_parts = kong_string.split(id, "-")
local id_count = #id_parts

local prefix
Expand All @@ -63,15 +63,15 @@ local function parse_phc(phc)
local params = {}
local prms = parts[3]
if prms then
local prm_parts = utils.split(prms, ",")
local prm_parts = kong_string.split(prms, ",")
for i = 1, #prm_parts do
local param = prm_parts[i]
local kv = utils.split(param, "=")
local kv = kong_string.split(param, "=")
local kv_count = #kv
if kv_count == 1 then
params[#params + 1] = infer(kv[1])
elseif kv_count == 2 then
local k = utils.strip(kv[1])
local k = kong_string.strip(kv[1])
params[k] = infer(kv[2])
else
return nil, "invalid phc string format for parameter"
Expand All @@ -96,9 +96,9 @@ local function parse_phc(phc)
end

return {
id = utils.strip(id),
prefix = utils.strip(prefix),
digest = utils.strip(digest),
id = kong_string.strip(id),
prefix = kong_string.strip(prefix),
digest = kong_string.strip(digest),
params = params,
salt = salt,
hash = hash,
Expand Down Expand Up @@ -133,7 +133,7 @@ if ENABLED_ALGORITHMS.ARGON2 then
}
do
local hash = argon2.hash_encoded("", get_rand_bytes(ARGON2_SALT_LEN), ARGON2_OPTIONS)
local parts = utils.split(hash, "$")
local parts = kong_string.split(hash, "$")
remove(parts)
remove(parts)
ARGON2_PREFIX = concat(parts, "$")
Expand Down Expand Up @@ -171,7 +171,7 @@ if ENABLED_ALGORITHMS.BCRYPT then

do
local hash = bcrypt.digest("", BCRYPT_ROUNDS)
local parts = utils.split(hash, "$")
local parts = kong_string.split(hash, "$")
remove(parts)
BCRYPT_PREFIX = concat(parts, "$")
end
Expand Down Expand Up @@ -253,7 +253,7 @@ if ENABLED_ALGORITHMS.PBKDF2 then

do
local hash = derive("")
local parts = utils.split(hash, "$")
local parts = kong_string.split(hash, "$")
remove(parts)
remove(parts)
PBKDF2_PREFIX = concat(parts, "$")
Expand Down
10 changes: 5 additions & 5 deletions kong/plugins/response-ratelimiting/header_filter.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local utils = require "kong.tools.utils"
local kong_string = require "kong.tools.string"


local kong = kong
Expand All @@ -22,15 +22,15 @@ local function parse_header(header_value, limits)
if type(header_value) == "table" then
parts = header_value
else
parts = utils.split(header_value, ",")
parts = kong_string.split(header_value, ",")
end

for _, v in ipairs(parts) do
local increment_parts = utils.split(v, "=")
local increment_parts = kong_string.split(v, "=")
if #increment_parts == 2 then
local limit_name = utils.strip(increment_parts[1])
local limit_name = kong_string.strip(increment_parts[1])
if limits[limit_name] then -- Only if the limit exists
increments[utils.strip(increment_parts[1])] = tonumber(utils.strip(increment_parts[2]))
increments[kong_string.strip(increment_parts[1])] = tonumber(kong_string.strip(increment_parts[2]))
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions kong/tracing/propagation/extractors/aws.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
local _EXTRACTOR = require "kong.tracing.propagation.extractors._base"
local propagation_utils = require "kong.tracing.propagation.utils"

local split = require "kong.tools.utils".split
local strip = require "kong.tools.utils".strip
local split = require "kong.tools.string".split
local strip = require "kong.tools.string".strip

local from_hex = propagation_utils.from_hex
local match = string.match
Expand Down
8 changes: 4 additions & 4 deletions spec/02-integration/02-cmd/10-migrations_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local helpers = require "spec.helpers"
local utils = require "kong.tools.utils"
local kong_string = require "kong.tools.string"
local DB = require "kong.db.init"
local tb_clone = require "table.clone"
local shell = require "resty.shell"
Expand Down Expand Up @@ -361,7 +361,7 @@ for _, strategy in helpers.each_strategy() do
plugins = "bundled"
}, true)
assert.equal(0, code)
assert.equal("Database is already up-to-date", utils.strip(stdout))
assert.equal("Database is already up-to-date", kong_string.strip(stdout))
assert.equal("", stderr)

code, stdout, stderr = run_kong("migrations up -f", {
Expand Down Expand Up @@ -400,14 +400,14 @@ for _, strategy in helpers.each_strategy() do
}, true)

assert.equal(0, code)
assert.equal("Database is already up-to-date", utils.strip(stdout))
assert.equal("Database is already up-to-date", kong_string.strip(stdout))
assert.equal("", stderr)

code, stdout, stderr = run_kong("migrations finish", {
plugins = "bundled"
}, true)
assert.equal(0, code)
assert.equal("No pending migrations to finish", utils.strip(stdout))
assert.equal("No pending migrations to finish", kong_string.strip(stdout))
assert.equal("", stderr)

code, stdout, stderr = run_kong("migrations finish -f", {
Expand Down

0 comments on commit b6ac910

Please sign in to comment.