about summary refs log tree commit diff
path: root/blaze822_priv.h
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2023-03-16 19:54:46 +0100
committerLeah Neukirchen <leah@vuxu.org>2023-03-16 19:54:46 +0100
commit1838158ef19d489e554b3460059fba47d26ba145 (patch)
treeb4e446f1bb93665cf574ef25bc40725969e66775 /blaze822_priv.h
parentcccf01cb9aa45769e2e9d41c1e8e98a6502a98e0 (diff)
downloadmblaze-1838158ef19d489e554b3460059fba47d26ba145.tar.gz
mblaze-1838158ef19d489e554b3460059fba47d26ba145.tar.xz
mblaze-1838158ef19d489e554b3460059fba47d26ba145.zip
blaze822_priv.h: use proper lc/uc
Mail headers may contain characters where the simple definition breaks,
which results in wrong formatting on output.

Fixes #235.
Diffstat (limited to 'blaze822_priv.h')
-rw-r--r--blaze822_priv.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/blaze822_priv.h b/blaze822_priv.h
index a84c963..e5f4a09 100644
--- a/blaze822_priv.h
+++ b/blaze822_priv.h
@@ -12,9 +12,9 @@ struct message {
 
 #define isfws(c)  (((unsigned char)(c) == ' ' || (unsigned char)(c) == '\t' || (unsigned char)(c) == '\n' || (unsigned char)(c) == '\r'))
 
-// ASCII lowercase/uppercase without alpha check (wrong for "@[\]^_")
-#define lc(c) ((c) | 0x20)
-#define uc(c) ((c) & 0xdf)
+// 7bit-ASCII only lowercase/uppercase
+#define lc(c) (((unsigned)(c)-'A') < 26 ? ((c) | 0x20) : (c))
+#define uc(c) (((unsigned)(c)-'a') < 26 ? ((c) & 0xdf) : (c))
 
 // dirent type that can be a mail/dir (following symlinks)
 #if defined(DT_REG) && defined(DT_LNK) && defined(DT_UNKNOWN)