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

core: Replace all illegal chars in disk aliases #408

Merged
merged 3 commits into from
Jun 21, 2022
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public class ImportVmFromExternalProviderCommand<T extends ImportVmFromExternalP

private static final Pattern VMWARE_DISK_NAME_PATTERN = Pattern.compile("\\[.*?\\] .*/(.*).vmdk");
private static final Pattern DISK_NAME_PATTERN = Pattern.compile(".*/([^.]+).*");
private static final Pattern DISK_ALIAS_ILLEGAL_CHARS_PATTERN = Pattern.compile("[^\\w.-]");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you allow only word chars? numeric is impossible? can you tell what exactly is illegal?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\w includes latin letters, digits and underscore. Also period (.) and hyphen (-) are allowed. These are characters that we allow for disk alias in WebAdmin.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\w includes latin letters, digits and underscore. Also period (.) and hyphen (-) are allowed. These are characters that we allow for disk alias in WebAdmin.

OK

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\w includes latin letters, digits and underscore. Also period (.) and hyphen (-) are allowed. These are characters that we allow for disk alias in WebAdmin.

so can we reuse the pattern that is used by the webadmin?


private static final String VDSM_COMPAT_VERSION_1_1 = "1.1";

Expand Down Expand Up @@ -369,7 +370,7 @@ && getStorageDomain().getStorageType().isBlockDomain()) {
}

private static String replaceInvalidDiskAliasChars(String alias) {
return alias.replace(' ', '_');
return DISK_ALIAS_ILLEGAL_CHARS_PATTERN.matcher(alias).replaceAll("_");
smelamud marked this conversation as resolved.
Show resolved Hide resolved
}

protected static String renameDiskAlias(OriginType originType, String alias) {
Expand Down