Browse Source

libobs/util: Also remove CR/LF from dstr_depad

Prevents newline characters from being included in things like stream
keys
jp9000 8 years ago
parent
commit
b8355c656c
1 changed files with 7 additions and 2 deletions
  1. 7 2
      libobs/util/dstr.c

+ 7 - 2
libobs/util/dstr.c

@@ -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;
 	}