-
Notifications
You must be signed in to change notification settings - Fork 151
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
Conversation
Signed-off-by: Colin Sullivan <[email protected]>
CI is green. |
There was a problem hiding this 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.
NATS.Client/Subscription.cs
Outdated
|
||
private static bool IsValidTokenOrQName(string value) | ||
{ | ||
return (!string.IsNullOrEmpty(value) && value.LastIndexOfAny(invalidSubjectChars) < 0); |
There was a problem hiding this comment.
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.
return (!string.IsNullOrEmpty(value) && value.LastIndexOfAny(invalidSubjectChars) < 0); | |
return (!string.IsNullOrEmpty(value) && value.IndexOfAny(invalidSubjectChars) < 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, thanks!
NATS.Client/Subscription.cs
Outdated
return false; | ||
} | ||
|
||
string[] tokens = subject.Split('.'); |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
NATS.Client/Subscription.cs
Outdated
/// </summary> | ||
/// <param name="subject">The subject to check</param> | ||
/// <returns>true if valid, false otherwise.</returns> | ||
static public bool IsValidSubject(string subject) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static public bool IsValidSubject(string subject) | |
public static bool IsValidSubject(string subject) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
NATS.Client/Subscription.cs
Outdated
/// </summary> | ||
/// <param name="queueGroup"></param> | ||
/// <returns>true is the queue group name is valid, false otherwise.</returns> | ||
static public bool IsValidQueueGroupName(string queueGroup) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static public bool IsValidQueueGroupName(string queueGroup) | |
public static bool IsValidQueueGroupName(string queueGroup) |
There was a problem hiding this comment.
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]>
Had a change of heart on the name and usage of the private method. |
Check for subject and queue name validity.
See:
Resolves #280
Signed-off-by: Colin Sullivan [email protected]