From ce48246b9b4e99ef3a23bb672b38fea2694bbc0f Mon Sep 17 00:00:00 2001 From: Stavros Kois <47820033+stavros-k@users.noreply.github.com> Date: Fri, 8 Oct 2021 10:27:13 +0300 Subject: [PATCH] (fix) Improve collabora's regex (#1108) * Improve collabora's regex * Also allow root domains, and disallow `--` * Shorten regex steps a bit --- .../collabora-online/SCALE/questions.yaml | 5 +-- .../stable/collabora-online/validation.md | 34 +++++++++++++++---- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/charts/stable/collabora-online/SCALE/questions.yaml b/charts/stable/collabora-online/SCALE/questions.yaml index 8deff2b7c0d..68265de8dd5 100644 --- a/charts/stable/collabora-online/SCALE/questions.yaml +++ b/charts/stable/collabora-online/SCALE/questions.yaml @@ -79,7 +79,7 @@ questions: schema: type: string default: 'nextcloud.domain.tld|othernextcloud.domain.tld' - valid_chars: '^([a-z]{1,}\.[a-z]{1,}\.[a-z]{1,})((\|[a-z]{1,}\.[a-z]{1,}\.[a-z]{1,}))*$' + valid_chars: '^(([a-z\d](-?[a-z\d]){0,62})\.)*(([a-z\d](-?[a-z\d]){0,62})\.)([a-z](-?[a-z\d]){1,62})((\|((([a-z\d](-?[a-z\d]){0,62})\.)*(([a-z\d](-?[a-z\d]){0,62})\.)([a-z](-?[a-z\d]){1,62})))*)$' required: true - variable: username label: "Username for WebUI" @@ -118,7 +118,8 @@ questions: schema: type: string default: 'collabora.domain.tld' - valid_chars: '^([a-z]{1,}\.[a-z]{1,}\.[a-z]{1,})$' + valid_chars: '^(([a-z\d](-?[a-z\d]){0,62})\.)*(([a-z\d](-?[a-z\d]){0,62})\.)([a-z](-?[a-z\d]){1,62})$' + # Include{containerConfig} - variable: service diff --git a/docs/apps/stable/collabora-online/validation.md b/docs/apps/stable/collabora-online/validation.md index c07d18b85c2..6c3ace80630 100644 --- a/docs/apps/stable/collabora-online/validation.md +++ b/docs/apps/stable/collabora-online/validation.md @@ -3,19 +3,39 @@ __`Domain(s) using collabora`__ Accepted formats are: -- Single domain (eg. `cloud.mydomain.com`) -- Multiple domains (eg. `cloud.mydomain.com|nextcloud.mydomain.com`) - Each domain is separated with `|` +- Single FQDN (eg. `cloud.mydomain.com` or `mydomain.com`) +- Multiple FQDN (eg. `cloud.mydomain.com|nextcloud.mydomain.com` or `mydomain.com|cname.mydomain.com`) - Each FQDN is separated with `|` -Regex used to match those: `^([a-z]{1,}\.[a-z]{1,}\.[a-z]{1,})((\|[a-z]{1,}\.[a-z]{1,}\.[a-z]{1,}))*$` -You can try live [here](https://regex101.com/r/AQFh2g/1) +Each FQDN is split into parts +* Hostname (`cname`.domain.com) _Optional_ + * Can have from 1 up to 127 levels deep cnames. + * Can contain [0-9], [a-z] and `-`. + * Must be at least 1 char and no longer than 63 chars. + * Must start with [a-z], [0-9]. + * Must NOT end with `-`. +* Domain (cname.`domain`.com) + * Can contain [0-9], [a-z] and `-`. + * Must be at least 1 chars and no longer than 63 chars. + * Must start with [a-z], [0-9]. + * Must NOT end with `-`. +* Top-Level-Domains (cname.domain.`com`) + * Can contain [0-9], [a-z] and `-`. + * Must be at least 2 chars and no longer than 63 chars. + * Must start with [a-z]. + * Must NOT end with `-`. + +Regex used to match those: `^(([a-z\d](-?[a-z\d]){0,62})\.)*(([a-z\d](-?[a-z\d]){0,62})\.)([a-z](-?[a-z\d]){1,62})((\|((([a-z\d](-?[a-z\d]){0,62})\.)*(([a-z\d](-?[a-z\d]){0,62})\.)([a-z](-?[a-z\d]){1,62})))*)$` +You can try live [here](https://regex101.com/r/rIxhye/1) __`Server Name`__ Accepted formats are: -- Single domain (eg. `collabora.mydomain.com`) +- Single FQDN (eg. `collabora.mydomain.com` or `mydomain.com`) -Regex used to match this: `^([a-z]{1,}\.[a-z]{1,}\.[a-z]{1,})$` -You can try live [here](https://regex101.com/r/xCjpW7/1) +_Same rules apply for FQDN as in the section above_ + +Regex used to match this: `^(([a-z\d](-?[a-z\d]){0,62})\.)*(([a-z\d](-?[a-z\d]){0,62})\.)([a-z](-?[a-z\d]){1,62})$` +You can try live [here](https://regex101.com/r/0HpkSI/1) __`Password for WebUI`__ Accepted formats are: