From 62441594ca46b49f938ab78a121befa86e72479f Mon Sep 17 00:00:00 2001 From: Harenson Henao Date: Tue, 7 Sep 2021 02:04:59 +0000 Subject: [PATCH 1/2] KTEL-10: Replace colons by dashes on fax attachments names When teletype sends a fax attachment, its name includes a time format that includes colons. Colons are not allowed characters for filenames in Windows and so many SMTP relays and mail servers will auto-correct the colon to a dash or underscore character. However, if the end user's server does not correct this, the resulting attachment is unopenable on Windows. --- applications/teletype/src/teletype_fax_util.erl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/applications/teletype/src/teletype_fax_util.erl b/applications/teletype/src/teletype_fax_util.erl index 1e6e25bf9b7..216451b62c9 100644 --- a/applications/teletype/src/teletype_fax_util.erl +++ b/applications/teletype/src/teletype_fax_util.erl @@ -242,4 +242,5 @@ get_file_name(Macros, Ext) -> end, LocalDateTime = props:get_value([<<"date_called">>, <<"local">>], Macros, <<"0000-00-00_00-00-00">>), FName = list_to_binary([CallerID, "_", kz_time:pretty_print_datetime(LocalDateTime), ".", Ext]), - re:replace(kz_term:to_lower_binary(FName), <<"\\s+">>, <<"_">>, [{'return', 'binary'}, 'global']). + ReOpts = [{'return', 'binary'}, 'global'], + re:replace(re:replace(kz_term:to_lower_binary(FName), <<"\\s+">>, <<"_">>, ReOpts), <<":">>, <<"-">>, ReOpts). From 48cb6ea3b4b9bcb0292a5ca8838d0abb9a159e5e Mon Sep 17 00:00:00 2001 From: Harenson Henao Date: Fri, 17 Sep 2021 16:46:23 +0000 Subject: [PATCH 2/2] KTEL-10: Split nested functions --- applications/teletype/src/teletype_fax_util.erl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/applications/teletype/src/teletype_fax_util.erl b/applications/teletype/src/teletype_fax_util.erl index 216451b62c9..ac055b067c7 100644 --- a/applications/teletype/src/teletype_fax_util.erl +++ b/applications/teletype/src/teletype_fax_util.erl @@ -243,4 +243,5 @@ get_file_name(Macros, Ext) -> LocalDateTime = props:get_value([<<"date_called">>, <<"local">>], Macros, <<"0000-00-00_00-00-00">>), FName = list_to_binary([CallerID, "_", kz_time:pretty_print_datetime(LocalDateTime), ".", Ext]), ReOpts = [{'return', 'binary'}, 'global'], - re:replace(re:replace(kz_term:to_lower_binary(FName), <<"\\s+">>, <<"_">>, ReOpts), <<":">>, <<"-">>, ReOpts). + NoSpaces = re:replace(kz_term:to_lower_binary(FName), <<"\\s+">>, <<"_">>, ReOpts), + re:replace(NoSpaces, <<":">>, <<"-">>, ReOpts).