Feature/unicode groupname validation (#1600)

Allow all UTF-8 characters except URL identifiers as user and group names and for namespaces.

Fixes #1513

Co-authored-by: René Pfeuffer <rene.pfeuffer@cloudogu.com>
This commit is contained in:
Eduard Heimbuch
2021-03-25 09:59:23 +01:00
committed by GitHub
parent 8f2272885b
commit 22a0362892
20 changed files with 299 additions and 358 deletions

View File

@@ -46426,7 +46426,6 @@ exports[`Storyshots Forms|AddKeyValueEntryToTableField Default 1`] = `
value=""
/>
</div>
</div>
<div
className="field AddKeyValueEntryToTableField__StyledInputField-kiarql-1 hwPPZB"
@@ -46450,7 +46449,6 @@ exports[`Storyshots Forms|AddKeyValueEntryToTableField Default 1`] = `
value=""
/>
</div>
</div>
<button
className="button is-default AddKeyValueEntryToTableField__MarginTopButton-kiarql-2 hyqVki"
@@ -46504,7 +46502,6 @@ exports[`Storyshots Forms|AddKeyValueEntryToTableField Disabled 1`] = `
value=""
/>
</div>
</div>
<div
className="field AddKeyValueEntryToTableField__StyledInputField-kiarql-1 hwPPZB"
@@ -46529,7 +46526,6 @@ exports[`Storyshots Forms|AddKeyValueEntryToTableField Disabled 1`] = `
value=""
/>
</div>
</div>
<button
className="button is-default AddKeyValueEntryToTableField__MarginTopButton-kiarql-2 hyqVki"

View File

@@ -37,6 +37,7 @@ type Props = {
onReturnPressed?: () => void;
validationError?: boolean;
errorMessage?: string;
informationMessage?: string;
disabled?: boolean;
helpText?: string;
className?: string;
@@ -86,6 +87,7 @@ class InputField extends React.Component<Props> {
value,
validationError,
errorMessage,
informationMessage,
disabled,
label,
helpText,
@@ -93,7 +95,12 @@ class InputField extends React.Component<Props> {
testId
} = this.props;
const errorView = validationError ? "is-danger" : "";
const helper = validationError ? <p className="help is-danger">{errorMessage}</p> : "";
let helper;
if (validationError) {
helper = <p className="help is-danger">{errorMessage}</p>;
} else if (informationMessage) {
helper = <p className="help is-info">{informationMessage}</p>;
}
return (
<div className={classNames("field", className)}>
<LabelWithHelpIcon label={label} helpText={helpText} />

View File

@@ -27,7 +27,7 @@ import { TFunction } from "i18next";
import { AstPlugin } from "./PluginApi";
import { Node, Parent } from "unist";
const namePartRegex = nameRegex.source.substring(1, nameRegex.source.length - 1);
const namePartRegex = nameRegex.source.substring(1, nameRegex.source.length - 1).replace(/\[\^([^\]s]+)\]/, "[^$1\\s]");
export const regExpPattern = `(${namePartRegex})\\/(${namePartRegex})@([\\w\\d]+)`;

View File

@@ -32,16 +32,15 @@ describe("test name validation", () => {
" test 123 ",
"test 123 ",
"test/123",
"test%123",
"test:123",
"t ",
" t",
" t ",
"",
" invalid_name",
"another%one",
"!!!",
"!_!"
"%",
"test%name",
"test\\name"
];
for (const name of invalidNames) {
it(`should return false for '${name}'`, () => {
@@ -52,6 +51,7 @@ describe("test name validation", () => {
// valid names taken from ValidationUtilTest.java
const validNames = [
"test",
"test git",
"test.git",
"Test123.git",
"Test123-git",
@@ -64,7 +64,18 @@ describe("test name validation", () => {
"another1",
"stillValid",
"this.one_as-well",
"and@this"
"and@this",
"Лорем-ипсум",
"Λορεμ.ιπσθμ",
"լոռեմիպսում",
"ლორემიფსუმ",
"प्रमान",
"詳性約",
"隠サレニ",
"법률",
"المدن",
"אחד",
"Hu-rëm"
];
for (const name of validNames) {
it(`should return true for '${name}'`, () => {

View File

@@ -22,7 +22,7 @@
* SOFTWARE.
*/
export const nameRegex = /^[A-Za-z0-9\.\-_][A-Za-z0-9\.\-_@]*$/;
export const nameRegex = /^(?:(?:[^:/?#;&=\s@%\\][^:/?#;&=%\\]*[^:/?#;&=\s%\\]+)|[^:/?#;&=\s@%\\])$/;
export const isNameValid = (name: string) => {
return nameRegex.test(name);