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

lib: IsNameValid(): disallow leading and trailing spaces #315

Merged
merged 2 commits into from
Nov 12, 2019

Conversation

pstorz
Copy link
Member

@pstorz pstorz commented Oct 31, 2019

Names with leading and trailing space are now illegal.
Also added a unit test that checks that IsNameValid() works
as expected.

Copy link
Member

@arogge arogge left a comment

Choose a reason for hiding this comment

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

Looks good. Maybe we also want to require that names to start with one of [A-Za-z0-9]?

@arogge
Copy link
Member

arogge commented Nov 6, 2019

If we added a second parameter const char* accept_additional that defaults to "" we could check this with strchr() in addition to accept so the caller could pass additional valid characters.

Then it should be possible to implement IsAclEntryValid() like this

bool IsAclEntryValid(const char* acl, char* msg) {
  if (acl[0] == '!') ++acl; // negated resource name/pattern, skip negation sign
  return IsNameValid(acl, msg, '.*')
}

Names with leading and trailing space are now illegal.
Also added a unit test that checks that IsNameValid() works
as expected.
@arogge arogge force-pushed the dev/pstorz/master/is_name_valid_refactor branch 2 times, most recently from d883ec6 to adcb0fd Compare November 12, 2019 11:31
@arogge arogge force-pushed the dev/pstorz/master/is_name_valid_refactor branch from adcb0fd to ca64964 Compare November 12, 2019 11:45
@arogge arogge merged commit 2523636 into master Nov 12, 2019
@arogge arogge deleted the dev/pstorz/master/is_name_valid_refactor branch November 12, 2019 13:37
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.

None yet

3 participants