mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
GEOM label: strip leading/trailing space synthesizing devfs names
%20%20%20 is ugly and doesn't really help make human-readable devfs names. PR: 243318 Reported by: Peter Eriksson <pen AT lysator.liu.se> Relnotes: yes
This commit is contained in:
parent
de8dd262c4
commit
151e04b3fe
1 changed files with 16 additions and 0 deletions
|
|
@ -179,9 +179,25 @@ g_label_mangle_name(char *label, size_t size)
|
|||
{
|
||||
struct sbuf *sb;
|
||||
const u_char *c;
|
||||
size_t len, i;
|
||||
|
||||
/* Trim trailing whitespace. */
|
||||
len = strlen(label);
|
||||
for (i = len; i > 0; i--) {
|
||||
if (isspace(label[i - 1]))
|
||||
label[i - 1] = '\0';
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (*label == '\0')
|
||||
return;
|
||||
|
||||
|
||||
sb = sbuf_new(NULL, NULL, size, SBUF_FIXEDLEN);
|
||||
for (c = label; *c != '\0'; c++) {
|
||||
/* Trim leading whitespace. */
|
||||
if (isspace(*c) && sbuf_len(sb) == 0)
|
||||
continue;
|
||||
if (!isprint(*c) || isspace(*c) || *c =='"' || *c == '%')
|
||||
sbuf_printf(sb, "%%%02X", *c);
|
||||
else
|
||||
|
|
|
|||
Loading…
Reference in a new issue