Fix trailing whitespace not being trimmed on acl users.

Closes #1539. Thanks to CliveJL and LeonPoon.
This commit is contained in:
Roger A. Light
2020-01-30 19:52:46 +00:00
parent 9a0de5ef61
commit 70fd600c3a
9 changed files with 238 additions and 9 deletions
+19
View File
@@ -17,6 +17,7 @@ Contributors:
#include "config.h"
#include <assert.h>
#include <ctype.h>
#include <string.h>
#ifdef WIN32
@@ -382,3 +383,21 @@ enum mosquitto_client_state mosquitto__get_state(struct mosquitto *mosq)
return state;
}
char *util__trimblanks(char *str)
{
char *endptr;
if(str == NULL) return NULL;
while(isblank(str[0])){
str++;
}
endptr = &str[strlen(str)-1];
while(endptr > str && isblank(endptr[0])){
endptr[0] = '\0';
endptr--;
}
return str;
}
+3
View File
@@ -47,4 +47,7 @@ void util__increment_receive_quota(struct mosquitto *mosq);
void util__increment_send_quota(struct mosquitto *mosq);
void util__decrement_receive_quota(struct mosquitto *mosq);
void util__decrement_send_quota(struct mosquitto *mosq);
char *util__trimblanks(char *str);
#endif