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

Validate the settings key if it's simple chars separated by . #16120

Merged
merged 2 commits into from Jan 20, 2016

Conversation

s1monw
Copy link
Contributor

@s1monw s1monw commented Jan 20, 2016

This adds additional safety to the settings since we don't have a full list of them
yet and it caught bugs already in tests.

This adds additional safety to the settings since we don't have a full list of them
yet and it caught bugs already in tests.
@@ -44,6 +45,9 @@
private final Map<String, Setting<?>> complexMatchers = new HashMap<>();
private final Map<String, Setting<?>> keySettings = new HashMap<>();
private final Setting.Scope scope;
private static final Pattern KEY_PATTERN = Pattern.compile("^([\\w\\d_-]+[.])*[\\w\\d_-]+$");

Choose a reason for hiding this comment

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

I think this should be:

^(?:[-\\w]+[.])*[-\\w]+$
  • non-capturing groups ((?:..)) are more efficient
  • \w already includes \d and _
  • a - inside [ ] should appear first, otherwise it indicates a range (at least in pcre)

@s1monw
Copy link
Contributor Author

s1monw commented Jan 20, 2016

@clintongormley I pushed updates :)

@clintongormley
Copy link

LGTM

s1monw added a commit that referenced this pull request Jan 20, 2016
Validate the settings key if it's simple chars separated by `.`
@s1monw s1monw merged commit 88bb79f into elastic:master Jan 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants