Skip to content

Commit

Permalink
revert to existing distribution of responsibilities
Browse files Browse the repository at this point in the history
  • Loading branch information
kentslaney committed Dec 1, 2023
1 parent 89d3153 commit 48c21f3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,17 @@ bool isLocalSocket(const char* host) {
}

void verifyPort(const char* input, ServerSpec* res, bool* valid_port) {
/*
if (*valid_port && input > res->port) {
res->port[-1] = '\0';
} else if (res->alias == NULL) {
res->port = NULL;
}
*valid_port = false;
*/
if (res->port != NULL) {
res->port[-1] = '\0';
}
}

// modifies input string and output pointers reference input
Expand Down
16 changes: 16 additions & 0 deletions tests/test_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@ TEST(test_unix, host_parse_regression) {
ASSERT_STREQ(out.alias, "testing");
}

TEST(test_unix, host_parse_regression_tripped) {
char test[] = "127.0.0.1:21211 127.0.0.1:21211";
ServerSpec out = splitServerString(test);
ASSERT_STREQ(out.host, "127.0.0.1");
ASSERT_STREQ(out.port, "21211");
ASSERT_STREQ(out.alias, "127.0.0.1:21211");
}

TEST(test_unix, tmpname) {
char test[] = "127.0.0.1:invalid_port";
ServerSpec out = splitServerString(test);
ASSERT_STREQ(out.host, "127.0.0.1");
ASSERT_STREQ(out.port, "invalid_port");
ASSERT_EQ(out.alias, nullptr);
}

TEST(test_unix, socket_path_spaces) {
char test[] = "/tmp/spacey\\ path testing";
ServerSpec out = splitServerString(test);
Expand Down

0 comments on commit 48c21f3

Please sign in to comment.