Skip to content

Commit

Permalink
Merge pull request #32 from JMolenkamp/main
Browse files Browse the repository at this point in the history
fix: validate channel names properly
  • Loading branch information
perkops authored Jun 13, 2024
2 parents c7af84a + 0b70108 commit 47dc10b
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ namespace Atc.Kepware.Configuration.Services;
[SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "OK")]
public sealed partial class KepwareConfigurationClient
{
private static readonly KeyStringAttribute ChannelNameKeyStringAttribute = new()
{
Required = true,
InvalidCharacters = ['.', '"'],
InvalidPrefixStrings = [" ", "_"],
RegularExpression = string.Empty,
};

public async Task<HttpClientRequestResult<bool>> IsChannelDefined(
string channelName,
CancellationToken cancellationToken)
Expand Down Expand Up @@ -767,7 +775,7 @@ private static bool IsValidConnectivityName(
string[]? tagGroupStructure,
out string? errorMessage)
{
if (!KeyStringAttribute.TryIsValid(channelName, out var errorMessageChannel))
if (!KeyStringAttribute.TryIsValid(channelName, ChannelNameKeyStringAttribute, out var errorMessageChannel))
{
errorMessage = errorMessageChannel;
return false;
Expand Down

0 comments on commit 47dc10b

Please sign in to comment.