hyphen = false;
}
- if (d > s && IN_SET(d[-1], '-', '.'))
+ while (d > s && IN_SET(d[-1], '-', '.'))
/* The dot can occur at most once, but we might have multiple
* hyphens, hence the loop */
d--;
ASSERT_STREQ(hostname_cleanup(s), "foo.bar");
s = strdupa_safe("foo.bar..");
ASSERT_STREQ(hostname_cleanup(s), "foo.bar");
+ s = strdupa_safe("foobar--");
+ ASSERT_STREQ(hostname_cleanup(s), "foobar");
+ s = strdupa_safe("foobar-.");
+ ASSERT_STREQ(hostname_cleanup(s), "foobar");
+ s = strdupa_safe("foobar.-");
+ ASSERT_STREQ(hostname_cleanup(s), "foobar");
+ s = strdupa_safe("foobar-.-");
+ ASSERT_STREQ(hostname_cleanup(s), "foobar");
s = strdupa_safe("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
ASSERT_STREQ(hostname_cleanup(s), "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
s = strdupa_safe("xxxx........xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");