diff --git a/src/lib-sieve/plugins/enotify/mailto/ntfy-mailto.c b/src/lib-sieve/plugins/enotify/mailto/ntfy-mailto.c index cb7265f4181eca008bfeb20c3b38d8b4780d8a30..fb345d52c4f77112a5a8c3c055304ff3b153816d 100644 --- a/src/lib-sieve/plugins/enotify/mailto/ntfy-mailto.c +++ b/src/lib-sieve/plugins/enotify/mailto/ntfy-mailto.c @@ -608,15 +608,15 @@ ntfy_mailto_send(const struct sieve_enotify_exec_env *nenv, /* Determine subject */ if (nact->message != NULL) { - /* FIXME: handle UTF-8 */ - subject = str_sanitize(nact->message, NTFY_MAILTO_MAX_SUBJECT); + subject = str_sanitize_utf8(nact->message, + NTFY_MAILTO_MAX_SUBJECT); } else if (subject == NULL) { const char *const *hsubject; /* Fetch subject from original message */ if (mail_get_headers_utf8(msgdata->mail, "subject", &hsubject) > 0) { - subject = str_sanitize( + subject = str_sanitize_utf8( t_strdup_printf("Notification: %s", hsubject[0]), NTFY_MAILTO_MAX_SUBJECT); } else { diff --git a/tests/extensions/enotify/mailto.svtest b/tests/extensions/enotify/mailto.svtest index 68d8daac8618a0f0a58824ea0a2a33feaa0ee8a8..1ca8e7cb2503f14c3967bbdbd1404a5805a10840 100644 --- a/tests/extensions/enotify/mailto.svtest +++ b/tests/extensions/enotify/mailto.svtest @@ -1,4 +1,5 @@ require "vnd.dovecot.testsuite"; +require "encoded-character"; require "enotify"; require "relational"; require "envelope"; @@ -539,3 +540,43 @@ decoded: ${decoded} ; } } + +/* + * Long message + */ + +test_result_reset; + +test_set "message" text: +From: stephan@example.org +To: nico@frop.example.org +Subject: Frop! + +Klutsefluts. +. +; + +test "Long message" { + notify :message "以ã¤ã‚ã¥èž65çµµã’ã¾å…¬å˜ã‚‡æ„›ç›Šã‚¤ãƒ©ãƒŒæ—…絵平ãƒèžçŽ‰ã‚†ãƒƒå¤œèƒ½ã‚»ãƒ¡ãƒ²æ˜ ç´™ãƒŠãƒãƒ²ãƒ©è¨˜50èž3里ヤé…石スりを先天ヤヌオク沢天7統併イよã‘ã’æœ€å‡¦è¼ªé‡‘ç›´ã¡ã‚¹ã€‚æ®ã‚å´å†™ã‚ˆã‚ƒé™å‚·ã˜ã°è±ŠéŠ˜ã‚‰ã½ã®ã»è«‡é€ ã’発変ã 際記タヨリ構始月ヨセ表軽ã™ã¥ãƒ«ç†ç‰¹é™¢ã–ã‚Œç”·éŒ²ã‚«ãƒæ¯Žå¿œã²ãトã“人復比イãµã€‚日ミノエ置æ¢ã‚¤è¨˜å ´ã‚¯ã‚¦è¦‹æœˆãƒªã‚·ãƒ’ス書電ã»ã‚“é–‹å¦äº•ワス逃6賞割セツ政転ã‚トã»ã‚Œæ’®è¿½ç·©ã›ã°ã»è·åŒºç§ä¸˜ç”˜ã‚ょã¯ã¤ã€‚交ルク秀57俸愚牡ç£1å®šãƒæŠ•å¼ãƒãƒ›ã‚¤ãƒ•会2掲ãトã¼ã¦ä¿å“ã¨ã˜ã–ã¡ç›´é‡‘ã‚¢ãƒãƒ’èª¿æ ¡ã‚¿æ›´ä¸‹ã¹ã¨ãƒ¼å£«èžãƒ†ã‚±ã‚ªè»½è¨˜ãƒ›ã‚«å北りã¾ã’ã»å¼åˆ†ã˜ã‚¯å´Žè„…ãã‚ãƒ³æ ¼æŠ±è¨ºéœ²ç«œã‚ルã¶ã‚¤ã€‚ä½ã‹ã å¯ç®¡ãƒ¦ãƒ©ãƒèµ·å‘ˆä½ãžã‚Šã¥ã›å‡ºéšŽãµæ–¹è†¨ã•ã³ãžä¸å£°ä¸çµ‚多散れよã©ã‚‰ä½•集ã‚ç ‚å²¡ãƒ¯å¤‰æ„›ç´°ã。陣ã‚ãšç¶šçš„ルん得法をã‘り科åŒç´¢ã‚ƒã†ãƒ³å±‹æˆ¸51俸愚牡ç£8常ヱアケ択先レフ度å‰ãƒŒã‚«ãƒ’本拡ケモç§ä½†ã¸ã‚„ドã³ç³»çƒåŸŸãƒ¡ã‚¿ãƒ¨ãƒå…¨èƒ½ãƒ„ヒ書指挙患慣ã¥ã€‚" + "mailto:stephan@example.org"; + + if not test_result_execute { + test_fail "failed to execute notify"; + } + + test_message :smtp 0; + + if not allof( + header :contains "subject" + "以ã¤ã‚ã¥èž65çµµã’ã¾å…¬å˜ã‚‡æ„›ç›Šã‚¤ãƒ©ãƒŒæ—…絵平ãƒèžçŽ‰ã‚†ãƒƒå¤œèƒ½ã‚»ãƒ¡ãƒ²æ˜ ç´™ãƒŠãƒãƒ²", + header :contains "subject" + "金アãƒãƒ’èª¿æ ¡ã‚¿æ›´ä¸‹ã¹ã¨ãƒ¼å£«èžãƒ†ã‚±ã‚ªè»½è¨˜ãƒ›ã‚«å北りã¾ã’ã»å¼åˆ†ã˜ã‚¯å´Žè„…ãã‚ãƒ³æ ¼æŠ±") { + test_fail "Subject header is too limited"; + } + if header :contains "subject" "ãã‚ãƒ³æ ¼æŠ±è¨ºéœ²" { + test_fail "Subject header is unlimited"; + } + if not header :matches "subject" "*${unicode:2026}" { + test_fail "Subject is missing ellipsis"; + } +}