diff --git a/CHANGELOG.md b/CHANGELOG.md index fbc470db2652..b9ad750f4e05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed dataset filter item representation for imageless dataset items () - Fixed interpreter crash when trying to import `tensorflow` with no AVX instructions available () - Kibana wrong working time calculation with new annotation UI use () +- Wrong rexex for account name validation () +- Wrong description on register view for the username field () +- Wrong resolution for resizing a shape () ### Security - SQL injection in Django `CVE-2020-9402` () diff --git a/cvat-canvas/src/typescript/canvasView.ts b/cvat-canvas/src/typescript/canvasView.ts index 002b4f093cf3..2220eff9c638 100644 --- a/cvat-canvas/src/typescript/canvasView.ts +++ b/cvat-canvas/src/typescript/canvasView.ts @@ -1401,7 +1401,9 @@ export class CanvasViewImpl implements CanvasView, Listener { let shapeSizeElement: ShapeSizeElement | null = null; let resized = false; - (shape as any).resize().on('resizestart', (): void => { + (shape as any).resize({ + snapToGrid: 0.1, + }).on('resizestart', (): void => { this.mode = Mode.RESIZE; if (state.shapeType === 'rectangle') { shapeSizeElement = displayShapeSize(this.adoptedContent, this.adoptedText); diff --git a/cvat-ui/src/components/register-page/register-form.tsx b/cvat-ui/src/components/register-page/register-form.tsx index daa38c8eddad..b2ace8869e62 100644 --- a/cvat-ui/src/components/register-page/register-form.tsx +++ b/cvat-ui/src/components/register-page/register-form.tsx @@ -11,7 +11,7 @@ import Checkbox from 'antd/lib/checkbox'; import patterns from 'utils/validation-patterns'; -import { UserAgreement } from 'reducers/interfaces' +import { UserAgreement } from 'reducers/interfaces'; import { Row, Col } from 'antd/lib/grid'; export interface UserConfirmation { @@ -31,7 +31,7 @@ export interface RegisterData { type RegisterFormProps = { fetching: boolean; - userAgreements: UserAgreement[], + userAgreements: UserAgreement[]; onSubmit(registerData: RegisterData): void; } & FormComponentProps; @@ -83,7 +83,7 @@ class RegisterFormComponent extends React.PureComponent { private validateAgrement = (agreement: any, value: any, callback: any): void => { const { userAgreements } = this.props; - let isValid: boolean = true; + let isValid = true; for (const userAgreement of userAgreements) { if (agreement.field === userAgreement.name && userAgreement.required && !value) { @@ -107,18 +107,20 @@ class RegisterFormComponent extends React.PureComponent { form.validateFields((error, values): void => { if (!error) { - values.confirmations = [] + const validatedFields = { + ...values, + confirmations: [], + }; for (const userAgreement of userAgreements) { - - values.confirmations.push({ + validatedFields.confirmations.push({ name: userAgreement.name, - value: values[userAgreement.name] + value: validatedFields[userAgreement.name], }); - delete values[userAgreement.name]; + delete validatedFields[userAgreement.name]; } - onSubmit(values); + onSubmit(validatedFields); } }); }; @@ -255,8 +257,7 @@ class RegisterFormComponent extends React.PureComponent { private renderUserAgreements(): JSX.Element[] { const { form, userAgreements } = this.props; - const getUserAgreementsElements = () => - { + const getUserAgreementsElements = (): JSX.Element[] => { const agreementsList: JSX.Element[] = []; for (const userAgreement of userAgreements) { agreementsList.push( @@ -269,18 +270,24 @@ class RegisterFormComponent extends React.PureComponent { message: 'You must accept to continue!', }, { validator: this.validateAgrement, - }] + }], })( - I read and accept the { userAgreement.displayText } - + I read and accept the + + {userAgreement.displayText} + + , )} - + , ); } return agreementsList; - } + }; return getUserAgreementsElements(); } diff --git a/cvat-ui/src/utils/validation-patterns.ts b/cvat-ui/src/utils/validation-patterns.ts index 8338990e42c3..f0b951508696 100644 --- a/cvat-ui/src/utils/validation-patterns.ts +++ b/cvat-ui/src/utils/validation-patterns.ts @@ -26,7 +26,7 @@ const validationPatterns = { validateUsernameLength: { pattern: /(?=.{5,})/, - message: 'Username must have at least 8 characters', + message: 'Username must have at least 5 characters', }, validateUsernameCharacters: { @@ -34,9 +34,19 @@ const validationPatterns = { message: 'Only characters (a-z), (A-Z), (0-9), -, _ are available', }, + /* + \p{Pd} - dash connectors + \p{Pc} - connector punctuations + \p{Cf} - invisible formatting indicator + \p{L} - any alphabetic character + Useful links: + https://stackoverflow.com/questions/4323386/multi-language-input-validation-with-utf-8-encoding + https://stackoverflow.com/questions/280712/javascript-unicode-regexes + https://stackoverflow.com/questions/6377407/how-to-validate-both-chinese-unicode-and-english-name + */ validateName: { // eslint-disable-next-line - pattern: /^[a-zA-Z]{2,}(([',. -][a-zA-Z ])?[a-zA-Z]*)*$/, + pattern: /^(\p{L}|\p{Pd}|\p{Cf}|\p{Pc}|['\s]){2,}$/gu, message: 'Invalid name', },