Index: openacs-4/packages/acs-mail-lite/tcl/acs-mail-lite-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-mail-lite/tcl/acs-mail-lite-procs.tcl,v diff -u -N -r1.104 -r1.105 --- openacs-4/packages/acs-mail-lite/tcl/acs-mail-lite-procs.tcl 19 Feb 2018 18:32:06 -0000 1.104 +++ openacs-4/packages/acs-mail-lite/tcl/acs-mail-lite-procs.tcl 19 Feb 2018 19:00:23 -0000 1.105 @@ -451,7 +451,7 @@ # Decision based firstly on parameter, # and then on other values that most likely could be substituted # with initial choice, and while meeting definition - # of originator header according to rfc 2822 section 3.6.2 + # of originator header according to RFC 2822 section 3.6.2 # https://tools.ietf.org/html/rfc2822#section-3.6.2 # A value must be provided. switch -exact -- $originator_email { Index: openacs-4/packages/acs-mail-lite/tcl/email-inbound-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-mail-lite/tcl/email-inbound-procs.tcl,v diff -u -N -r1.4 -r1.5 --- openacs-4/packages/acs-mail-lite/tcl/email-inbound-procs.tcl 19 Feb 2018 18:32:06 -0000 1.4 +++ openacs-4/packages/acs-mail-lite/tcl/email-inbound-procs.tcl 19 Feb 2018 19:00:23 -0000 1.5 @@ -194,8 +194,9 @@ set v_p 1 } else { set v_p [regexp -- {^[[:graph:]\ ]+$} $new(${spn})] - if { $v_p && \ - [string match {*[\[;]*} $new(${spn}) ] } { + if { $v_p + && [string match {*[\[;]*} $new(${spn})] + } { set v_p 0 } } @@ -345,15 +346,17 @@ set size_error_p 0 # validate email inputs - if { ! ([string is wideinteger -strict $size_chars] \ - && $size_chars > 0) } { + if { ! ([string is wideinteger -strict $size_chars] + && $size_chars > 0) + } { set size_error_p 1 ns_log Warning "acs_mail_lite::inbound_prioritize.283: \ size_chars '${size_chars}' is not a natural number." } set time_error_p 0 - if { ! ([string is wideinteger -strict $received_cs] \ - && $received_cs > 0) } { + if { ! ([string is wideinteger -strict $received_cs] + && $received_cs > 0) + } { set time_error_p 1 ns_log Warning "acs_mail_lite::inbound_prioritize.289: \ received_cs '${received_cs}' is not a natural number." @@ -548,7 +551,7 @@ # header cases: {*auto-generated*} {*auto-replied*} {*auto-notified*} # from: # https://www.iana.org/assignments/auto-submitted-keywords/auto-submitted-keywords.xhtml - # and rfc3834 https://www.ietf.org/rfc/rfc3834.txt + # and RFC 3834 https://www.ietf.org/rfc/rfc3834.txt # Do NOT use x-auto-response-suppress # per: https://stackoverflow.com/questions/1027395/detecting-outlook-autoreply-out-of-office-emails @@ -623,7 +626,7 @@ set hn_list [array names h_arr] ns_log Dev "acs_mail_lite::email_type.996 hn_list '${hn_list}'" - # Following checks according to rfc3834 section 3.1 Message header + # Following checks according to RFC 3834 section 3.1 Message header # https://tools.ietf.org/html/rfc3834 @@ -633,7 +636,7 @@ # This is a new message id, not message id of email replied to set mi_idx [lsearch -glob -nocase $hn_list {message-id}] - # Also per rfc5436 seciton 2.7.1 consider: + # Also per RFC 5436 section 2.7.1 consider: # auto-submitted = as set as_idx [lsearch -glob -nocase $hn_list {auto-submitted}] @@ -699,9 +702,10 @@ - if { !$ar_p && [info exists h_arr(internaldate.year)] \ - && $from ne "" } { - + if { !$ar_p + && [info exists h_arr(internaldate.year)] + && $from ne "" + } { # Use the internal timestamp for additional filters set dti $h_arr(internaldate.year) append dti "-" [format "%02u" $h_arr(internaldate.month)] @@ -817,10 +821,10 @@ set dt_h [lindex $hn_list $dt_idx] # Cannot use optional ns_imap parsedate here. May not exist. - # rfc5322 section 3.3: multiple spaces in date is acceptable + # RFC 5322 section 3.3: multiple spaces in date is acceptable # but not for tcl clock scan -format - regsub -all -- {[ ][ ]*} $h_arr(${dt_h}) { } dt_spaced - # rfc5322 section 3.3: obs-zone breaks clock scan format too + regsub -all -- { +} $h_arr(${dt_h}) { } dt_spaced + # RFC 5322 section 3.3: obs-zone breaks clock scan format too set dt_spaced_tz_idx [string first " (" $dt_spaced] set dt_spaced [string trim [string range $dt_spaced 0 ${dt_spaced_tz_idx} ]] set dte_cs [clock scan $dt_spaced -format "%a, %d %b %G %H:%M:%S %z"] @@ -865,13 +869,13 @@ } - # Delivery Status Notifications, see rfc3464 + # Delivery Status Notifications, see RFC 3464 # https://tools.ietf.org/html/rfc3464 # Note: original-envelope-id is not same as message-id. # original-recipient = or set or_idx [lsearch -glob -nocase $hn_list {original-recipient}] if { $or_idx < 0 } { - # RFC3461 4.2 uses original-recipient-address + # RFC 3461 4.2 uses original-recipient-address set or_idx [lsearch -glob \ -nocase $hn_list {original-recipient-address}] } @@ -950,7 +954,7 @@ set ps3 [string match -nocase {*autoreply*} $subject] set ps4 [string match {*NDN*} $subject] set ps5 [string match {*\[QuickML\] Error*} $subject] - # rfc3834 states to NOT rely on 'Auto: ' in subject for detection. + # RFC 3834 states to NOT rely on 'Auto: ' in subject for detection. #set ps6 \[string match {Auto: *} $subject\] # from flags = pf @@ -972,8 +976,9 @@ # an in_reply_to does NOT include 'auto_gen'. if { $dsn_p || $or_idx > -1 } { set type "bounce" - } elseif { $ar_p || ( $irt_idx > -1 && \ - ( $ag_p || $as_p || $an_p || $ts_p ) ) } { + } elseif { $ar_p + || ( $irt_idx > -1 && ( $ag_p || $as_p || $an_p || $ts_p ) ) + } { set type "auto_reply" } elseif { $ag_p || $as_p || $an_p || $ts_p } { set type "auto_gen" @@ -1508,7 +1513,7 @@ from acs_mail_lite_ie_parts where aml_email_id=:aml_email_id } ] foreach row $p_lists { - set section_ref [acs_mail_lite::seciton_ref_of [lindex $row 0]] + set section_ref [acs_mail_lite::section_ref_of [lindex $row 0]] set p_arr(${section_ref},c_type) [lindex $row 1] set p_arr(${section_ref},filename) [lindex $row 2] set p_arr(${section_ref},content) [lindex $row 3] @@ -1725,7 +1730,7 @@ If already exists, returns 1 otherwise 0. Adds checked case to cache if not already there. - uidvalidity is defined by imap rfc3501 2.3.1.1 + uidvalidity is defined by imap RFC 3501 2.3.1.1 https://tools.ietf.org/html/rfc3501#section-2.3.1.1 Other protocols have an analog mechanism, or one can be made locally to be equivallent in use. @@ -1871,10 +1876,11 @@ } set aml_package_id [apm_package_id_from_key "acs-mail-lite"] - if { ( $package_id ne "" && $package_id ne $aml_package_id ) \ - || ( $party_id ne "" && $party_id ne "0" ) \ - || $object_id ne "" \ - || $other ne "" } { + if { ( $package_id ne "" && $package_id ne $aml_package_id ) + || ( $party_id ne "" && $party_id ne "0" ) + || $object_id ne "" + || $other ne "" + } { # Sign this message-id, and map message-id to values set uid [string range $unique_id 0 $last_at_idx-1] set domain [string range $unique_id $last_at_idx+1 end] @@ -2089,7 +2095,7 @@ # and acs_mail_lite::unique_id_create/find/parse - # Bounce info needs to be placed in an rfc + # Bounce info needs to be placed in an RFC # compliant header. Replies can take many forms. # This could be a mess. # If a service using MailDir switches to use IMAP, @@ -2100,19 +2106,19 @@ # General constraints: # Header field characters limited to US-ASCII characters between 33 and 126 - # inclusive per rfc5322 2.2 https://tools.ietf.org/html/rfc5322#section-2.2 + # inclusive per RFC 5322 2.2 https://tools.ietf.org/html/rfc5322#section-2.2 # and white-space characters 32 and 9. - # Per rfc6532 3.3 and 5322 2.1.1, "Each line of characters must be no more + # Per RFC 6532 3.3 and 5322 2.1.1, "Each line of characters must be no more # than 998 characters, and should be no more than 78 characters.." # A domain name can take up to 253 characters. # Setting aside about 60 characters for a signature for a signed message-id # should be okay even though it almost guarantees all cases of message_id # will be over 78 characters. - # Unique references are case sensitive per rfc3464 2.2.1 - # original email's envelope-id value is case sensitive per rfc3464 2.2.1 + # Unique references are case sensitive per RFC 3464 2.2.1 + # original email's envelope-id value is case sensitive per RFC 3464 2.2.1 # Angle brackets are used to quote a unique reference @@ -2121,27 +2127,27 @@ # original-message-id # original-envelope-id - # message-id a unique message id per rfc2822 3.6.4 - # assigned by originator per rfc5598 3.4.1 + # message-id a unique message id per RFC 2822 3.6.4 + # assigned by originator per RFC 598 3.4.1 # https://tools.ietf.org/html/rfc5598#section-3.4.1 # # originator A special case alternate to 'From' header. # Usually defined by first SMTP MTA. # Notices may be sent to this address when # a bounce notice to the original email's 'From' # address bounces. - # See RFC5321 2.3.1 + # See RFC 5321 2.3.1 # https://tools.ietf.org/html/rfc5321#section-2.3.1 - # and RFC5598 2.2.1 + # and RFC 5598 2.2.1 # https://tools.ietf.org/html/rfc5598#section-2.1 # msg-id - # In-Reply-to space delimited list of unique message ids per rfc2822 3.6.4 - # References space delimited list of unique message ids per rfc2822 3.6.4 + # In-Reply-to space delimited list of unique message ids per RFC 2822 3.6.4 + # References space delimited list of unique message ids per RFC 2822 3.6.4 # # original-recipient may contain original 'to' address of party_id # original-recipient-address # is an alternate to original-recipient - # used by rfc3461 4.2 + # used by RFC 3461 4.2 # https://tools.ietf.org/html/rfc3461#section-4.2 # Recipient could be used as an extra layer # of authentication after parsing. @@ -2290,27 +2296,27 @@ } set context_list [acs_mail_lite::unique_id_parse \ -message_id $hv] - if { $h_arr(aml_datetime_cs) eq "" \ - && [string match "${bounce_addrs}*" $hv] } { + if { $h_arr(aml_datetime_cs) eq "" + && [string match "${bounce_addrs}*" $hv] + } { - ##code developers of OpenACS core: # Legacy case should be removed for strict, secure # handling of context info # Check legacy case # Regexp code is from acs_mail_lite::parse_bounce_address - if { [regexp $regexp_str $hv \ - all user_id signature package_id] } { + if { [regexp $regexp_str $hv all user_id signature package_id] } { set context_list [list \ package_id $package_id \ party_id $user_id \ object_id "" \ other "" ] set sig_list [split $signature "."] set sig_1 [lindex $sig_list 1] - if { [llength $sig_list ] == 3 \ - && [string is wideinteger -strict $sig_1] } { + if { [llength $sig_list ] == 3 + && [string is wideinteger -strict $sig_1] + } { lappend context_list datetime_cs $sig_1 } else { lappend context_list datetime_cs [clock seconds] @@ -2408,8 +2414,9 @@ } # end code from acs_mail_lite::record_bounce - if { $h_arr(aml_party_id) ne $user_id \ - || $h_arr(aml_datetime_cs) eq "" } { + if { $h_arr(aml_party_id) ne $user_id + || $h_arr(aml_datetime_cs) eq "" + } { # Log it, because it might be a false positive. # Existence of aml_datetime_cs means unique_id was signed. # See acs_mail_lite::unique_id_parse Index: openacs-4/packages/acs-mail-lite/tcl/imap-inbound-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-mail-lite/tcl/imap-inbound-procs.tcl,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/acs-mail-lite/tcl/imap-inbound-procs.tcl 18 Feb 2018 10:41:58 -0000 1.2 +++ openacs-4/packages/acs-mail-lite/tcl/imap-inbound-procs.tcl 19 Feb 2018 19:00:23 -0000 1.3 @@ -134,8 +134,9 @@ set v_p 1 } else { set v_p [regexp -- {^[[:graph:]\ ]+$} $n_arr(${n})] - if { $v_p && \ - [string match {*[\[;]*} $n_arr(${n}) ] } { + if { $v_p + && [string match {*[\[;]*} $n_arr(${n}) ] + } { set v_p 0 } } @@ -546,9 +547,9 @@ after $pause_ms } - if { [clock seconds] < $si_quit_cs \ - && $active_cs eq $cycle_start_cs } { - + if { [clock seconds] < $si_quit_cs + && $active_cs eq $cycle_start_cs + } { set cid [acs_mail_lite::imap_conn_go ] if { $cid eq "" } { set error_p 1 @@ -568,9 +569,9 @@ } array set status_arr $status_list set uidvalidity $status_arr(Uidvalidity) - if { [info exists status_arr(Uidnext) ] \ - && [info exists status_arr(Messages) ] } { - + if { [info exists status_arr(Uidnext)] + && [info exists status_arr(Messages)] + } { set aml_package_id [apm_package_id_from_key "acs-mail-lite"] set filter_proc [parameter::get -parameter "IncomingFilterProcName" \ -package_id $aml_package_id] @@ -672,7 +673,7 @@ Either Uidnext or Messages not in status_list: '${status_list}'" } - if { [expr { [clock seconds] + 65 } ] < $si_quit_cs } { + if { [clock seconds] + 65 < $si_quit_cs } { # Regardless of parameter SMPTTimeout, # if there is more than 65 seconds to next cycle, # close connection @@ -793,8 +794,10 @@ set p_arr(${section_id},c_type) $type lappend p_arr(section_id_list) ${section_id} - if { [info exists bytes] && $bytes > $__max_txt_bytes \ - && ![info exists filename] } { + if { [info exists bytes] + && $bytes > $__max_txt_bytes + && ![info exists filename] + } { set filename "blob.txt" } @@ -844,11 +847,10 @@ # 72 character wide lines * x lines set msg_start_max [expr { 72 * 20 } ] set msg_txtb [string range $msg_txt 0 $msg_start_max] - if { [string length $msg_txt] \ - > [expr { $msg_start_max + 400 } ] } { + set msg_len [string length $msg_txt] + if { $msg_len > $msg_start_max + 400 } { set msg_txte [string range $msg_txt end-$msg_start_max end] - } elseif { [string length $msg_txt] \ - > [expr { $msg_start_max + 144 } ] } { + } elseif { $msg_len > $msg_start_max + 144 } { set msg_txte [string range $msg_txt end-144 end] } else { set msg_txte "" Index: openacs-4/packages/acs-mail-lite/tcl/maildir-inbound-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-mail-lite/tcl/maildir-inbound-procs.tcl,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/acs-mail-lite/tcl/maildir-inbound-procs.tcl 18 Feb 2018 10:41:58 -0000 1.3 +++ openacs-4/packages/acs-mail-lite/tcl/maildir-inbound-procs.tcl 19 Feb 2018 19:00:23 -0000 1.4 @@ -215,7 +215,7 @@ upvar 1 __max_txt_bytes __max_txt_bytes set has_parts_p 0 set section_n_v_list [list ] - # rfc 822 date time format regexp expression + # RFC 822 date time format regexp expression set re822 {[^a-z]([a-z][a-z][a-z][ ,]+[0-9]+ [a-z][a-z][a-z][ ]+[0-9][0-9][0-9][0-9][ ]+[0-9][0-9][:][0-9][0-9][:][0-9][0-9][ ]+[\+\-][0-9]+)[^0-9]} if { ![info exists __max_txt_bytes] } { @@ -358,12 +358,14 @@ set p_arr(${section_id},c_type) $type lappend p_arr(section_id_list) ${section_id} - if { [info exists bytes] && $bytes > $__max_txt_bytes \ - && ![info exists filename] } { + if { [info exists bytes] + && $bytes > $__max_txt_bytes + && ![info exists filename] + } { set filename "blob.txt" } - if { [info exists filename ] } { + if { [info exists filename] } { set filename2 [clock microseconds] append filename2 "-" $filename set filepathname [file join [acs_root_dir] \ @@ -410,11 +412,9 @@ # 72 character wide lines * x lines set msg_start_max [expr { 72 * 20 } ] set msg_txtb [string range $msg_txt 0 $msg_start_max] - if { [string length $msg_txt] \ - > [expr { $msg_start_max + 400 } ] } { + if { [string length $msg_txt] > $msg_start_max + 400 } { set msg_txte [string range $msg_txt end-$msg_start_max end] - } elseif { [string length $msg_txt] \ - > [expr { $msg_start_max + 144 } ] } { + } elseif { [string length $msg_txt] > $msg_start_max + 144 } { set msg_txte [string range $msg_txt end-144 end] } else { set msg_txte "" Index: openacs-4/packages/acs-mail-lite/tcl/utils-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-mail-lite/tcl/utils-procs.tcl,v diff -u -N -r1.6 -r1.7 --- openacs-4/packages/acs-mail-lite/tcl/utils-procs.tcl 30 Sep 2017 17:42:32 -0000 1.6 +++ openacs-4/packages/acs-mail-lite/tcl/utils-procs.tcl 19 Feb 2018 19:00:23 -0000 1.7 @@ -109,9 +109,10 @@ if { [catch {package require mime 1.5.2}] } { set gmt [clock format $clock -format "%Y-%m-%d %H:%M:%S" -gmt true] - if {[set diff [expr {($clock-[clock scan $gmt])/60}]] < 0} { + set diff [expr {($clock - [clock scan $gmt]) / 60}] + if {$diff < 0} { set s - - set diff [expr {-($diff)}] + set diff [expr {-$diff}] } else { set s + }