Skip to content

Commit b9ca411

Browse files
fix: relax local part validator (#189)
Builtin group "Domain Admins" name contains a space. Relax the general address local part validator and require strict validation only in the add-address action. Refs NethServer/dev#7533
1 parent d54931b commit b9ca411

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

imageroot/actions/add-address/validate-input.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
],
1919
"allOf": [
2020
{
21-
"$ref": "http://schema.nethserver.org/mail.json#/$defs/mail-address"
21+
"$ref": "http://schema.nethserver.org/mail.json#/$defs/mail-address-strict"
2222
}
2323
]
2424
}

imageroot/validator-definitions.json

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@
310310
"type": "string",
311311
"title": "Address local part",
312312
"minLength": 1,
313-
"pattern": "^[a-zA-Z0-9](?:[a-zA-Z0-9._-]*[a-zA-Z0-9])?$"
313+
"pattern": "^[^@]+$"
314314
},
315315
"atype": {
316316
"type": "string",
@@ -335,6 +335,26 @@
335335
}
336336
}
337337
},
338+
"mail-address-strict": {
339+
"description": "Strict validation of mail address local part",
340+
"allOf": [
341+
{
342+
"$ref": "#/$defs/mail-address-base"
343+
},
344+
{
345+
"properties": {
346+
"local": {
347+
"type": "string",
348+
"title": "Address local part",
349+
"description": "Strict validation of local part",
350+
"minLength": 1,
351+
"pattern": "^[a-zA-Z0-9](?:[a-zA-Z0-9._-]*[a-zA-Z0-9])?$"
352+
353+
}
354+
}
355+
}
356+
]
357+
},
338358
"mail-address-change-request": {
339359
"title": "Mail address change request",
340360
"description": "An object describing how to modify an existing mail address object",
@@ -1080,4 +1100,4 @@
10801100
]
10811101
}
10821102
}
1083-
}
1103+
}

tests/40__api/20__addresses.robot

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ Check users and groups addresses are in the address list
1919
Add a user address alias
2020
Run task module/${MID}/add-address {"atype":"domain","local":"u1-alias","domain":"${test_domain}","destinations":[{"dtype":"user","name":"u1"}]}
2121

22+
Add invalid address
23+
Run task module/${MID}/add-address {"atype":"domain","local":"u1 alias","domain":"${test_domain}","destinations":[{"dtype":"user","name":"u1"}]}
24+
... rc_expected=10
25+
2226
Add a group address alias
2327
Run task module/${MID}/add-address {"atype":"domain","local":"g1-alias","domain":"${test_domain}","destinations":[{"dtype":"group","name":"g1"}]}
2428

0 commit comments

Comments
 (0)