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

Check for subject and queue name validity #279

Merged
merged 2 commits into from
Aug 26, 2019
Merged

Conversation

ColinSullivan1
Copy link
Member

@ColinSullivan1 ColinSullivan1 commented Aug 26, 2019

Signed-off-by: Colin Sullivan <[email protected]>
@ColinSullivan1
Copy link
Member Author

CI is green.

Copy link
Collaborator

@watfordgnf watfordgnf left a comment

Choose a reason for hiding this comment

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

Few comments, but otherwise looks fine.


private static bool IsValidTokenOrQName(string value)
{
return (!string.IsNullOrEmpty(value) && value.LastIndexOfAny(invalidSubjectChars) < 0);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't know if LastIndexOfAny has received the perf improvements that IndexOfAny has as of .NET Core.

Suggested change
return (!string.IsNullOrEmpty(value) && value.LastIndexOfAny(invalidSubjectChars) < 0);
return (!string.IsNullOrEmpty(value) && value.IndexOfAny(invalidSubjectChars) < 0);

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, thanks!

return false;
}

string[] tokens = subject.Split('.');
Copy link
Collaborator

Choose a reason for hiding this comment

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

If this is ever on the hot path (e.g. Publish) we'll want to avoid Split.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll add a comment.

/// </summary>
/// <param name="subject">The subject to check</param>
/// <returns>true if valid, false otherwise.</returns>
static public bool IsValidSubject(string subject)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
static public bool IsValidSubject(string subject)
public static bool IsValidSubject(string subject)

Copy link
Member Author

Choose a reason for hiding this comment

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

+1

/// </summary>
/// <param name="queueGroup"></param>
/// <returns>true is the queue group name is valid, false otherwise.</returns>
static public bool IsValidQueueGroupName(string queueGroup)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
static public bool IsValidQueueGroupName(string queueGroup)
public static bool IsValidQueueGroupName(string queueGroup)

Copy link
Member Author

Choose a reason for hiding this comment

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

+1

Signed-off-by: Colin Sullivan <[email protected]>
@ColinSullivan1
Copy link
Member Author

Had a change of heart on the name and usage of the private method.

@ColinSullivan1 ColinSullivan1 merged commit d2be064 into master Aug 26, 2019
@ColinSullivan1 ColinSullivan1 deleted the subject-check branch September 27, 2019 01:31
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.

Check for subject and queue name validity
2 participants