Sanitize app names and shorten screenshot names #349

Merged
navodzoysa merged 2 commits from ashvini/device-mgt-core:Improvement-#9241 into master 11 months ago
Fixes: https://roadmap.entgra.net/issues/9241 https://roadmap.entgra.net/issues/10628
ashvini added 1 commit 11 months ago
navodzoysa requested changes 11 months ago
* @return Sanitized and shortened file name
*/
public static String sanitizeName(String originalName, String type) {
String sanitizedName = originalName.replaceAll("[^a-zA-Z0-9.\\s-]", "");
Collaborator

Can move the regex pattern to a constant as it could be reused in the future.

Can move the regex pattern to a constant as it could be reused in the future.
*/
public static String sanitizeName(String originalName, String type) {
String sanitizedName = originalName.replaceAll("[^a-zA-Z0-9.\\s-]", "");
if (type.equals(Constants.ApplicationProperties.NAME) && sanitizedName.length() > 350) {
Collaborator

Use the constant on the left side of the comparison to avoid null pointer exception.

Also avoid using magic numbers (350) instead use a constant like MAX_CHARACTER_LENGTH

Use the constant on the left side of the comparison to avoid null pointer exception. Also avoid using magic numbers (350) instead use a constant like MAX_CHARACTER_LENGTH
}
return type + fileExtension;
} else
return sanitizedName;
Collaborator

Enclose else condition with curly braces for better readability.

Enclose else condition with curly braces for better readability.
ashvini added 1 commit 11 months ago
ashvini requested review from navodzoysa 11 months ago
navodzoysa merged commit 464214fe1b into master 11 months ago

Reviewers

navodzoysa was requested for review 11 months ago
The pull request has been merged as 464214fe1b.
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: community/device-mgt-core#349
Loading…
There is no content yet.