Skip to content

Forbid 'String.matches(String)' API.#778

Draft
cpoerschke wants to merge 1 commit intoapache:mainfrom
cpoerschke:forbid-String-matches
Draft

Forbid 'String.matches(String)' API.#778
cpoerschke wants to merge 1 commit intoapache:mainfrom
cpoerschke:forbid-String-matches

Conversation

@cpoerschke
Copy link
Copy Markdown
Contributor

In favour of reusable compiled patterns.

No JIRA issue as yet.

}

private static Map<String, String> selectForIndex(int i, Map<String, String> original) {
final Pattern pattern = Pattern.compile("(((?!^router\\.).)*$|(^router\\." + i + ".*$))");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

probably can make this a static final field?


public static String[] validateCollections(String collections[]) {
String collectionNameRegex = "^[a-zA-Z0-9_-]*$";
Pattern collectionNameRegexPattern = Pattern.compile("^[a-zA-Z0-9_-]*$");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

probably can make this a static final field?

path = request.substring(0, queryStartPos);
}
if (!query.matches(".*wt=schema\\.xml.*")) { // don't overwrite wt=schema.xml
final Pattern WT_SCHEMA_XML_PATTERN = Pattern.compile(".*wt=schema\\.xml.*");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This can probably be a static final field.

@risdenk
Copy link
Copy Markdown
Contributor

risdenk commented Oct 27, 2022

This in general seems like a good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants