Skip to content
This repository has been archived by the owner on Feb 18, 2021. It is now read-only.

Fix path-regex to allow for number only strings #216

Merged
merged 2 commits into from
Jun 5, 2017
Merged

Conversation

kirg
Copy link
Contributor

@kirg kirg commented May 31, 2017

Our internal canaries use a shortened-uuid to in the latter part of the path to create destinations/CGs. Occasionally, when this results in a pure numeric string, the create destination/cg fails .. because our regular expressions that validate paths seem to (incorrectly?) enforce there is at least one 'alphabetic' character in each part of the path -- while our comment seems to indicate that we are only trying to enforce each part has at least one non-symbolic character.

@@ -127,13 +127,13 @@ func (r *resolverImpl) cachePut(key string, value string) {
// so names like /./. aren't valid

// PathRegex regex for destination path
var PathRegex = regexp.MustCompile(`^/[\w.]*[a-zA-Z][\w.]*/[\w.]*[a-zA-Z][\w.]*$`)
var PathRegex = regexp.MustCompile(`^/[\w.]*[[:alnum:]][\w.]*/[\w.]*[[:alnum:]][\w.]*$`)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you have pure numeric path components? /w already allows a-z, A-Z, 0-9, including the _ (underscore), so it seems like you can have a bunch of numbers as long as you have at least one letter with the current system.

Copy link
Contributor Author

@kirg kirg Jun 2, 2017

Choose a reason for hiding this comment

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

Yes, the canary uses a 'shortened' UUID for the second part of the component .. and that sometimes results in a purely numeric string in the second component of the path -- which would fail to match the original regex (that expects at least one non-numeric character in each component of the path).

@kirg kirg changed the title Fix path regexs to allow for number only strings in latter Fix path-regex to allow for number only strings Jun 3, 2017
@kirg kirg merged commit 26d5f39 into master Jun 5, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants