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

Regex cleanup #79

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
21 changes: 9 additions & 12 deletions app/src/main/java/com/platform/assets/AssetsValidation.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,20 @@ public class AssetsValidation {

public final static String ROOT_NAME_CHARACTERS = "^[A-Z0-9._]{3,}$";
private final static String SUB_NAME_CHARACTERS = "^[A-Z0-9._]+$";
//private final static String UNIQUE_TAG_CHARACTERS = "^[-A-Za-z0-9@$%&*()\\]{}<>_.;?\\\\:]+$";
// private final static String UNIQUE_TAG_CHARACTERS = "^[-A-Za-z0-9@$%&*()\\[\\]{}<>_.;?\\\\:]+$";
private final static String UNIQUE_TAG_CHARACTERS = "^[-A-Za-z0-9@$%&*()\\\\{}_.?:]+$";
//private final static String UNIQUE_TAG_CHARACTERS = "^[-A-Za-z0-9@$%&*()[\\]{}<>_.;?\\\\:]+$";
private final static String CHANNEL_TAG_CHARACTERS = "^[A-Z0-9._]+$";
private final static String UNIQUE_TAG_CHARACTERS = "^[-A-Za-z0-9@$%&*()[\\\\]{}_.?:]+$";
private final static String MSG_CHANNEL_TAG_CHARACTERS = "^[A-Za-z0-9_]+$";

private final static String DOUBLE_PUNCTUATION = "^.*[._]{2,}.*$";
private final static String LEADING_PUNCTUATION = "^[._].*$";
private final static String TRAILING_PUNCTUATION = "^.*[._]$";

public final static String SUB_NAME_DELIMITER = "/";
public final static String UNIQUE_TAG_DELIMITER = "#";
private final static String CHANNEL_TAG_DELIMITER = "~";
private final static String MSG_CHANNEL_TAG_DELIMITER = "~";

private final static String UNIQUE_INDICATOR = "^[^#]+#[^#]+$";
private final static String CHANNEL_INDICATOR = "^[^~]~[^~]$";
private final static String OWNER_INDICATOR = "^[^!]+!$";
private final static String UNIQUE_INDICATOR = "^[^^~#!]+#[^~#!\\/]+$";
private final static String MSG_CHANNEL_INDICATOR = "^[^^~#!]+~[^~#!\\/]+$";
private final static String OWNER_INDICATOR = "^[^^~#!]+!$";

private final static String RAVEN_NAMES = "^RVN|^RAVEN|^RAVENCOIN|^RAVENC0IN|^RAVENCO1N|^RAVENC01N";

Expand All @@ -47,7 +44,7 @@ private static boolean isUniqueTagValid(final String tag) {
}

private static boolean isChannelTagValid(final String tag) {
return tag.matches(CHANNEL_TAG_CHARACTERS) &&
return tag.matches(MSG_CHANNEL_TAG_CHARACTERS) &&
tag.matches(DOUBLE_PUNCTUATION) &&
tag.matches(LEADING_PUNCTUATION) &&
tag.matches(TRAILING_PUNCTUATION);
Expand Down Expand Up @@ -94,12 +91,12 @@ public static boolean isAssetNameValid(final String name, AssetType assetType) {
}
assetType = AssetType.UNIQUE;
return true;
} else if (name.matches(CHANNEL_INDICATOR)) {
} else if (name.matches(MSG_CHANNEL_INDICATOR)) {
if (name.length() > MAX_NAME_LENGTH) {
return false;
}

String[] parts = name.split(CHANNEL_TAG_DELIMITER,-1);
String[] parts = name.split(MSG_CHANNEL_TAG_DELIMITER,-1);

if (parts.length > 0) {
int lastItemIndex = parts.length - 1;
Expand Down