Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch of fixes #1667

Merged
merged 6 commits into from
Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed dataset filter item representation for imageless dataset items (https://github.com/opencv/cvat/pull/1593)
- Fixed interpreter crash when trying to import `tensorflow` with no AVX instructions available (https://github.com/opencv/cvat/pull/1567)
- Kibana wrong working time calculation with new annotation UI use (<https://github.com/opencv/cvat/pull/1654>)
- Wrong rexex for account name validation (<https://github.com/opencv/cvat/pull/1667>)
- Wrong description on register view for the username field (<https://github.com/opencv/cvat/pull/1667>)
- Wrong resolution for resizing a shape (<https://github.com/opencv/cvat/pull/1667>)

### Security
- SQL injection in Django `CVE-2020-9402` (https://github.com/opencv/cvat/pull/1657)
Expand Down
4 changes: 3 additions & 1 deletion cvat-canvas/src/typescript/canvasView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion cvat-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cvat-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cvat-ui",
"version": "1.2.1",
"version": "1.2.2",
"description": "CVAT single-page application",
"main": "src/index.tsx",
"scripts": {
Expand Down
41 changes: 24 additions & 17 deletions cvat-ui/src/components/register-page/register-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -31,7 +31,7 @@ export interface RegisterData {

type RegisterFormProps = {
fetching: boolean;
userAgreements: UserAgreement[],
userAgreements: UserAgreement[];
onSubmit(registerData: RegisterData): void;
} & FormComponentProps;

Expand Down Expand Up @@ -83,7 +83,7 @@ class RegisterFormComponent extends React.PureComponent<RegisterFormProps> {

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) {
Expand All @@ -107,18 +107,20 @@ class RegisterFormComponent extends React.PureComponent<RegisterFormProps> {

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);
}
});
};
Expand Down Expand Up @@ -255,8 +257,7 @@ class RegisterFormComponent extends React.PureComponent<RegisterFormProps> {

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(
Expand All @@ -269,18 +270,24 @@ class RegisterFormComponent extends React.PureComponent<RegisterFormProps> {
message: 'You must accept to continue!',
}, {
validator: this.validateAgrement,
}]
}],
})(
<Checkbox>
I read and accept the <a rel='noopener noreferrer' target='_blank'
href={ userAgreement.url }>{ userAgreement.displayText }</a>
</Checkbox>
I read and accept the
<a
rel='noopener noreferrer'
target='_blank'
href={userAgreement.url}
>
{userAgreement.displayText}
</a>
</Checkbox>,
)}
</Form.Item>
</Form.Item>,
);
}
return agreementsList;
}
};

return getUserAgreementsElements();
}
Expand Down
14 changes: 12 additions & 2 deletions cvat-ui/src/utils/validation-patterns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,27 @@ const validationPatterns = {

validateUsernameLength: {
pattern: /(?=.{5,})/,
message: 'Username must have at least 8 characters',
message: 'Username must have at least 5 characters',
},

validateUsernameCharacters: {
pattern: /^[a-zA-Z0-9_-]{5,}$/,
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',
},

Expand Down