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

refactor: fix polynomial expression issue fix #9

Merged
merged 1 commit into from
Feb 15, 2023
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
2 changes: 1 addition & 1 deletion packages/components/src/components/numpad/numpad.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const Numpad = ({
if (String(default_value) === '0') {
updateValue(concatenate(num, ''));
} else {
const regex = /(?:\d+\.)(\d+)$/;
const regex = /(?:\d+\.)?(\d+)$/;
const matches = regex.exec(default_value);

if (matches !== null && is_float) {
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/utils/files/file-uploader-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const truncateFileName = (file: TFile, limit: number) => {
};

export const getFileExtension = (file: TFile) => {
const f = file?.type?.match(/[^/]+$/);
const f = file?.type?.match(/[^\/]+$/);

Check failure

Code scanning / CodeQL

Polynomial regular expression used on uncontrolled data

This [regular expression](1) that depends on [library input](2) may run slow on strings with many repetitions of '.'. This [regular expression](1) that depends on [library input](3) may run slow on strings with many repetitions of '.'. This [regular expression](1) that depends on [library input](4) may run slow on strings with many repetitions of '.'.
return f && f[0];
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const validPostCode = (value: string) => value === '' || /^[A-Za-z0-9][A-
export const validTaxID = (value: string) => /(?!^$|\s+)[A-Za-z0-9./\s-]$/.test(value);
export const validPhone = (value: string) => /^\+?([0-9-]+\s)*[0-9-]+$/.test(value);
// export const validLetterSymbol = (value: string) => /^[A-Za-z]+([a-zA-Z.' -])*[a-zA-Z.' -]+$/.test(value);
//Added regex constructor to make it as object
export const validLetterSymbol = (value: string) => {
const pattern = "^[A-Za-z]+([a-zA-Z.' -])*[a-zA-Z.' -]+$";
const regex = new RegExp(pattern);
Expand Down