libobs/util: Also remove CR/LF from dstr_depad

Prevents newline characters from being included in things like stream
keys
This commit is contained in:
jp9000
2017-05-20 11:11:14 -07:00
parent fa09e6743d
commit b8355c656c

View File

@@ -197,6 +197,11 @@ wchar_t *wstrstri(const wchar_t *str, const wchar_t *find)
return NULL;
}
static inline bool is_padding(char ch)
{
return ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r';
}
char *strdepad(char *str)
{
char *temp;
@@ -210,7 +215,7 @@ char *strdepad(char *str)
temp = str;
/* remove preceding spaces/tabs */
while (*temp == ' ' || *temp == '\t')
while (is_padding(*temp))
++temp;
len = strlen(str);
@@ -219,7 +224,7 @@ char *strdepad(char *str)
if (len) {
temp = str + (len-1);
while (*temp == ' ' || *temp == '\t')
while (is_padding(*temp))
*(temp--) = 0;
}