mirror of
https://gitee.com/iresty/apisix.git
synced 2024-12-04 21:17:36 +08:00
feat: remove restriction of label pattern to support Chinese (#3379)
* feat: remove restriction of label pattern to support Chinese Fix #3378. Signed-off-by: spacewander <spacewanderlzx@gmail.com> * whitespace Signed-off-by: spacewander <spacewanderlzx@gmail.com>
This commit is contained in:
parent
62b5f7c6d4
commit
64029e0ecc
@ -81,7 +81,7 @@ local remote_addr_def = {
|
||||
local label_value_def = {
|
||||
description = "value of label",
|
||||
type = "string",
|
||||
pattern = [[^[a-zA-Z0-9-_.]+$]],
|
||||
pattern = [[^\S+$]],
|
||||
maxLength = 64,
|
||||
minLength = 1
|
||||
}
|
||||
|
@ -518,3 +518,96 @@ GET /t
|
||||
{"error_msg":"only one of remote_addr or remote_addrs is allowed"}
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 15: labels in Chinese
|
||||
--- config
|
||||
location /t {
|
||||
content_by_lua_block {
|
||||
local t = require("lib.test_admin").test
|
||||
local code, body = t('/apisix/admin/routes/1',
|
||||
ngx.HTTP_PUT,
|
||||
[[{
|
||||
"methods": ["GET"],
|
||||
"upstream": {
|
||||
"nodes": {
|
||||
"127.0.0.1:8080": 1
|
||||
},
|
||||
"type": "roundrobin"
|
||||
},
|
||||
"labels": {
|
||||
"您好": "世界"
|
||||
},
|
||||
|
||||
"uri": "/index.html"
|
||||
}]],
|
||||
[[{
|
||||
"node": {
|
||||
"value": {
|
||||
"methods": [
|
||||
"GET"
|
||||
],
|
||||
"uri": "/index.html",
|
||||
"upstream": {
|
||||
"nodes": {
|
||||
"127.0.0.1:8080": 1
|
||||
},
|
||||
"type": "roundrobin"
|
||||
},
|
||||
"labels": {
|
||||
"您好": "世界"
|
||||
}
|
||||
},
|
||||
"key": "/apisix/routes/1"
|
||||
},
|
||||
"action": "set"
|
||||
}]]
|
||||
)
|
||||
|
||||
ngx.status = code
|
||||
ngx.say(body)
|
||||
}
|
||||
}
|
||||
--- request
|
||||
GET /t
|
||||
--- response_body
|
||||
passed
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 16: labels value with whitespace
|
||||
--- config
|
||||
location /t {
|
||||
content_by_lua_block {
|
||||
local t = require("lib.test_admin").test
|
||||
local code, body = t('/apisix/admin/routes/1',
|
||||
ngx.HTTP_PUT,
|
||||
[[{
|
||||
"methods": ["GET"],
|
||||
"upstream": {
|
||||
"nodes": {
|
||||
"127.0.0.1:8080": 1
|
||||
},
|
||||
"type": "roundrobin"
|
||||
},
|
||||
"labels": {
|
||||
"您好": "世 界"
|
||||
},
|
||||
"uri": "/index.html"
|
||||
}]]
|
||||
)
|
||||
|
||||
ngx.status = code
|
||||
ngx.say(body)
|
||||
}
|
||||
}
|
||||
--- request
|
||||
GET /t
|
||||
--- error_code: 400
|
||||
--- response_body_like eval
|
||||
qr/invalid configuration: property \\"labels\\" validation failed/
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
Loading…
Reference in New Issue
Block a user