r5404: allow spaces in the string representation of nbt names
[kai/samba.git] / source4 / libcli / nbt / nbtname.c
index fc87c2f4b227710199b3eba63d0039b352989b93..bf545a63743d2ae1d6590c02bb3362ce37644b9d 100644 (file)
@@ -334,10 +334,11 @@ static const char *nbt_hex_encode(TALLOC_CTX *mem_ctx, const char *s)
 {
        int i, len;
        char *ret;
-       const char *valid_chars = "_-.$@";
+       const char *valid_chars = "_-.$@ ";
+#define NBT_CHAR_ALLOW(c) (isalnum(c) || strchr(valid_chars, c))
 
        for (len=i=0;s[i];i++,len++) {
-               if (!isalnum(s[i]) && !strchr(valid_chars, s[i])) {
+               if (!NBT_CHAR_ALLOW(s[i])) {
                        len += 2;
                }
        }
@@ -346,7 +347,7 @@ static const char *nbt_hex_encode(TALLOC_CTX *mem_ctx, const char *s)
        if (ret == NULL) return NULL;
 
        for (len=i=0;s[i];i++) {
-               if (isalnum(s[i]) || strchr(valid_chars, s[i])) {
+               if (NBT_CHAR_ALLOW(s[i])) {
                        ret[len++] = s[i];
                } else {
                        snprintf(&ret[len], 4, "%%%02x", (unsigned char)s[i]);