-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Remove rex_pcre dependency from core #167
Comments
👍 |
I am actually not sure if this is going to be possible. Places where we need a regex, checked if a test case with a working pattern is provided:
uuidlocal x = "%x"
local pattern = "^"..table.concat({ x:rep(8), x:rep(4), x:rep(4), x:rep(4), x:rep(12) }, '%-').."$"
local guid = "3F2504E0-4F89-41D3-9A0C-0305E82C3301"
assert(guid:match(pattern))
guid = "fba88588-ffd0-4769-c782-7c537c92078d"
assert(guid:match(pattern))
guid = "fba88588-ffd0-4769-c782-7c537c92078dblah"
assert(not guid:match(pattern))
guid = "blahfba88588-ffd0-4769-c782-7c537c92078d"
assert(not guid:match(pattern))
guid = "3F2504E0-4F89-41D3-9A0C0305E82C3301"
assert(not guid:match(pattern))
guid = "304E0-4F89-41D3-9A0C0305E8^3301"
assert(not guid:match(pattern))
guid = "fba88588-féd0-4769-c782-7c537c92078d"
assert(not guid:match(pattern))
guid = "fba88588-(§è!)-4769-c782-7c537c92078d"
assert(not guid:match(pattern))
guid = "3F2504E0-4F89-41D3-9A0§-03(5E82C3301"
assert(not guid:match(pattern))
guid = "3F2504E0-4F89-41D3-9A0C0305é82C3301"
assert(not guid:match(pattern))
guid = "hello3F2504E0-4F89-41D3-9A0C0305é82C3301world"
assert(not guid:match(pattern))
guid = "abcd"
assert(not guid:match(pattern))
guid = ""
assert(not guid:match(pattern)) public_dnslocal function is_valid_public_dns(str)
-- check the format
local pattern1 = "([A-Za-z0-9%-]*)%.*([A-Za-z0-9%-]*)%.([A-Za-z0-9][A-Za-z0-9]+)$"
-- check all characters are alphanumeric
local pattern2 = "^[%w%.%-]*$"
-- both checks need to be true to be a valid public_dns
return str:match(pattern1) and str:match(pattern2)
end
assert(is_valid_public_dns("mockbin.com"))
assert(is_valid_public_dns("foo-bar.mockbin.com"))
assert(is_valid_public_dns("mockbin.com"))
assert(is_valid_public_dns("mockbin.ninja"))
assert(is_valid_public_dns("api.mockbin.com"))
assert(not is_valid_public_dns("apiè!!.mockbin.com"))
assert(not is_valid_public_dns(""))
assert(not is_valid_public_dns("mockbincom"))
assert(not is_valid_public_dns( "mockbincom!!"))
assert(not is_valid_public_dns("mockbin.com!!"))
assert(not is_valid_public_dns("mockbin.com.")) specsIn the specs I was able to use a simple pattern to extract JSON string from a log line: local json_str = line:match("(%{.*%})") |
If if it's not feasible to remove it from everywhere, we shouldn't force it. Just reduce regex usage to the places where it's absolutely necessary would be okay. |
It might be possible, we might also use a slightly more enhanced way of using the patterns (like a library: http://www.inf.puc-rio.br/~roberto/lpeg/lpeg.html) |
Just updated the issue with a working version of a |
Updated for the specs part too |
Merged #167 which does some improvements and use patterns in most places instead of regexes. PCRE is not removed and the |
) * chore(ci) [skip travis] move nightly releases to Jenkins * [skip travis] * [skip travis] split plugin tests out and login to docker when building the docker test image * [skip travis] try a different way of defining the KONG_VERSION env * [skip travis] skip the problematic builds * [skip travis] move the daily deploys out of travis.yml * [skip travis] wip debugging a sporadically failing test * fix(tests) adjust how we run the report mock server for a more reliable test * chore(ci) debug the environment variables available in jenkins [skip travis] * chore(ci) set the repository os name environment variable [skip travis] * test(reports) adjust how we check if the report server can run * chore(ci) adjust the jenkins setup [skip travis] * chore(wip) remove the integration tests to focus on getting the nightly releases to work * fix(ci) adjust how set set the bintray credentials [skip travis] * wip -- debugging daily releases to bintray [skip travis] * chore(ci) run only the xenial release [skip travis] * chore(ci) re-enable tests and other distribution releases * chore(ci) add the CI cron trigger chore(dependency) bump the kong-build-tools dependency (#168) chore(dependencies) adjust kong-build-tools dependency pin (#169) * chore(dependency) bump the kong-build-tools dependency * chore(ci) unpin the jenkins build from the kong-build-tools branch chore(nightly) build nightly arm release (#171) chore(ci) adjust cache settings for xenail nightly builds (#173)
) * chore(ci) [skip travis] move nightly releases to Jenkins * [skip travis] * [skip travis] split plugin tests out and login to docker when building the docker test image * [skip travis] try a different way of defining the KONG_VERSION env * [skip travis] skip the problematic builds * [skip travis] move the daily deploys out of travis.yml * [skip travis] wip debugging a sporadically failing test * fix(tests) adjust how we run the report mock server for a more reliable test * chore(ci) debug the environment variables available in jenkins [skip travis] * chore(ci) set the repository os name environment variable [skip travis] * test(reports) adjust how we check if the report server can run * chore(ci) adjust the jenkins setup [skip travis] * chore(wip) remove the integration tests to focus on getting the nightly releases to work * fix(ci) adjust how set set the bintray credentials [skip travis] * wip -- debugging daily releases to bintray [skip travis] * chore(ci) run only the xenial release [skip travis] * chore(ci) re-enable tests and other distribution releases * chore(ci) add the CI cron trigger chore(dependency) bump the kong-build-tools dependency (#168) chore(dependencies) adjust kong-build-tools dependency pin (#169) * chore(dependency) bump the kong-build-tools dependency * chore(ci) unpin the jenkins build from the kong-build-tools branch chore(nightly) build nightly arm release (#171) chore(ci) adjust cache settings for xenail nightly builds (#173)
Use Lua patterns instead.
The text was updated successfully, but these errors were encountered: