Skip to content

Commit

Permalink
Merge pull request #430 from jjnicola/underscore
Browse files Browse the repository at this point in the history
Accept underscore as valid char in hostname strings
  • Loading branch information
bjoernricks authored Jan 28, 2021
2 parents cd1299f + 9970323 commit a406413
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Increase minimum gpgme version [#405](https://github.com/greenbone/gvm-libs/pull/405)
- Always NULL check ifaddrs->ifa_addr [#416](https://github.com/greenbone/gvm-libs/pull/416)
- Correct g_hash_table_remove arg [#419](https://github.com/greenbone/gvm-libs/pull/419)
- Accept underscore as valid char in hostname strings [#429](https://github.com/greenbone/gvm-libs/pull/429)

[20.8.1]: https://github.com/greenbone/gvm-libs/compare/v20.8.0...gvm-libs-20.08

Expand Down
2 changes: 1 addition & 1 deletion base/hosts.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ is_hostname (const char *str)

point = split;
while (*point)
if (g_regex_match_simple ("^(?!-)[a-z0-9-]{1,63}(?<!-)$", *point,
if (g_regex_match_simple ("^(?!-)[a-z0-9_-]{1,63}(?<!-)$", *point,
G_REGEX_CASELESS, 0)
== 0)
{
Expand Down
4 changes: 4 additions & 0 deletions base/hosts_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ Ensure (hosts, gvm_get_host_type_returns_host_type_hostname)
{
assert_that (gvm_get_host_type ("www.greenbone.net"),
is_equal_to (HOST_TYPE_NAME));
assert_that (gvm_get_host_type ("www.example_underscore.net"),
is_equal_to (HOST_TYPE_NAME));
assert_that (gvm_get_host_type ("www.example-dash.net"),
is_equal_to (HOST_TYPE_NAME));
assert_that (gvm_get_host_type ("greenbone.net"),
is_equal_to (HOST_TYPE_NAME));
assert_that (gvm_get_host_type ("g"), is_equal_to (HOST_TYPE_NAME));
Expand Down

0 comments on commit a406413

Please sign in to comment.