You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by ju...@apache.org on 2021/01/21 13:27:09 UTC
[apisix] branch master updated: feat: remove restriction of label
pattern to support Chinese (#3379)
This is an automated email from the ASF dual-hosted git repository.
juzhiyuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new 64029e0 feat: remove restriction of label pattern to support Chinese (#3379)
64029e0 is described below
commit 64029e0eccb7c9d48b036f5c112ed962fbe5b3c2
Author: 罗泽轩 <sp...@gmail.com>
AuthorDate: Thu Jan 21 07:27:00 2021 -0600
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 <sp...@gmail.com>
* whitespace
Signed-off-by: spacewander <sp...@gmail.com>
---
apisix/schema_def.lua | 2 +-
t/admin/routes2.t | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 94 insertions(+), 1 deletion(-)
diff --git a/apisix/schema_def.lua b/apisix/schema_def.lua
index a94a99a..a15fa83 100644
--- a/apisix/schema_def.lua
+++ b/apisix/schema_def.lua
@@ -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
}
diff --git a/t/admin/routes2.t b/t/admin/routes2.t
index 7357250..269671e 100644
--- a/t/admin/routes2.t
+++ b/t/admin/routes2.t
@@ -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]