chiark / gitweb /
journal: fix export of messages containing newlines
[elogind.git] / src / shared / utf8.c
index 0b524d8a9041eae0348382cdf47159f7c2f8d0b3..c559c13678d62b7cd275f05721febe73b5205924 100644 (file)
@@ -136,7 +136,7 @@ int utf8_encoded_to_unichar(const char *str) {
         return unichar;
 }
 
-bool utf8_is_printable(const char* str, size_t length) {
+bool utf8_is_printable_newline(const char* str, size_t length, bool newline) {
         const uint8_t *p;
 
         assert(str);
@@ -145,7 +145,8 @@ bool utf8_is_printable(const char* str, size_t length) {
                 int encoded_len = utf8_encoded_valid_unichar((const char *)p);
                 int val = utf8_encoded_to_unichar((const char*)p);
 
-                if (encoded_len < 0 || val < 0 || is_unicode_control(val))
+                if (encoded_len < 0 || val < 0 || is_unicode_control(val) ||
+                    (!newline && val == '\n'))
                         return false;
 
                 length -= encoded_len;