Subject: Sug (ID Q26RT):

From: Dimakopoulos Panagiotis <[email-masked]>
Date: Mon, 25 Mar 1996 19:23:38 +0200 (EET)

I do not think that pine 3.92 handles properly messages with 8 bit chars
which are supposed to be part of a specific char set such as ISO-8859-7
(greek chars) which I used for my experiments.

The point is that when we choose to set on or off the two configuration
options

[ ]  enable-8bit-esmtp-negotiation
[ ]  enable-8bit-nntp-posting

from the setup menu the encodings do not follow the encodings implied by
the above settings in all the configurations. To tell such cases more
precisely I have dome experiments where:

1. I have tried to post a news article with greek chars both on the
subject and in the body. When an nntp server is not specified then
pine uses the "inews" utility which knows where to post the article.
In this case, no matter what was the setting of enable-8bit-nntp-posting
the message arrived encoded in MIME on the host which collects the
news postings for our LAN. Certainly that was not a problem of the
local configuration because I used inews manually and it DID post
an 8bit article to the server by keeping the 8 bits both in the body
and in the subject.

2. As a follow-up of the previous experiment I set the nntp-server
from the configuration menu and I repeated the same procedure. In
that case the message encoding was following the

[ ]  enable-8bit-nntp-posting

value but only for the body and not for the Subject which arrived
MIME encoded all the time.

3. Also when there is no smtp-server (which keeps the name of the
mail relay) defined then the mail arrives always MIME encoded
no matter whether

[ ]  enable-8bit-esmtp-negotiation

is set or not.

Definitely it is not because of the flags the sendmail is called
by pine with.

My personal view is that when we ask for an 8 bit transmission the
message should arrive at the final host in 8 bits no matter if a
mail relay intervenes in the journey or not. I had a look in the
code and I realised that indeed the F_ENABLE_8BIT flag is not
checked for all cases of transmission.

As an attempt to prove to myself that the problem was inside pine I
made some modifications to the code (only in file send.c) which
I am including as an attachment to this mail. And this seemms to
work fine for all the above cases that I have talked about before.
I am not issuing this as an official patch - I just send it to you
as a possible help for the points where further encoding or encoding
prevention is necessary.

I hope I have not misunderstood something for all the above behaviour.

Thank you,

           ------------------------------------------------------
           | Panos Dimakopoulos             [email-masked]      |
           | COMPUTER TECHNOLOGY INSTITUTE                      |
           | P.O. Box 1122                                      |
           | 261 10 Patras, Greece                              |
           | Tel (+30) 61 992061, 994317    Fax (+30) 61 993973 |
           ------------------------------------------------------
*** send.c.orig	Sun Mar 24 16:55:29 1996
--- send.c	Mon Mar 25 17:21:13 1996
***************
*** 55,60 ****
--- 55,62 ----
  #endif

  #define	MIME_VER	"MIME-Version: 1.0\015\012"
+ int required_8bits=0;		/* dimakop */
+ int post_or_mail=0;	/* 1 for post - 2 for mail */

  /*
***************
*** 2721,2727 ****
--- 2723,2731 ----
  		    pf_ref->localcopy = 1;
  		}

+ post_or_mail = 1;
  		news_result = news_poster(&header, *body); /* try posting */
+ post_or_mail = 0;

  		if(news_result < 0){
  		    dprint(1, (debugfile, "Post failed, continuing\n"));
***************
*** 2746,2753 ****
  	    }

              /*------- Actually mail the message ------*/
!             if(outgoing->to || outgoing->cc || outgoing->bcc || lcc_addr)
  	      mail_result = call_mailer(&header, *body);

  	    /*----- Was there an fcc involved? -----*/
              if(local_so){
--- 2750,2759 ----
  	    }

              /*------- Actually mail the message ------*/
!             if(outgoing->to || outgoing->cc || outgoing->bcc || lcc_addr) {
! 		post_or_mail = 2;		/* dimakop */
  	      mail_result = call_mailer(&header, *body);
+ 		}

  	    /*----- Was there an fcc involved? -----*/
              if(local_so){
***************
*** 2772,2777 ****
--- 2778,2784 ----

  		so_give(&local_so);
  	    }
+ 		post_or_mail = 0;		/* dimakop */

              /*----- Both weren't OK, back to composer -----*/
              if(mail_result < 0 && news_result != 1){
***************
*** 3661,3666 ****
--- 3668,3679 ----

  #define MAX_ADDR_ERROR 2  /* Only display 2 address errors */

+     required_8bits = (F_ON(F_ENABLE_8BIT, ps_global));	/* dimakop */
+ 					/* The required_8bits is set whenever a
+ 					 * message is to be sent by mail (not news)
+ 					 * and it has to be in 8 bits.
+ 					 */
+
      dprint(4, (debugfile, "Sending mail...\n"));

      /* Check for any recipients */
***************
*** 5115,5125 ****
      int        writehdr, localcopy;
  {
      char *p;

      *(p = tmp) = '\0';
      rfc822_header_line(&p, field, header ? header->env : NULL,
! 		       rfc1522_encode(tmp_20k_buf, (unsigned char *) text,
! 				      ps_global->VAR_CHAR_SET));
      return(((writehdr && f) ? (*f)(s, tmp) : 1)
           && ((localcopy && local_so
  	     && !local_written) ? so_puts(local_so,tmp) : 1));
--- 5128,5151 ----
      int        writehdr, localcopy;
  {
      char *p;
+     int  is_8bits_required = 0;
+     int  news_or_mail_8bits = 0;
+
+     if ( sending_stream && sending_stream->ok_8bitmime )
+ 		is_8bits_required = 1;
+     else	is_8bits_required = 0;		/* from news */

+     if ( post_or_mail==1 )	/* posting */
+ 	    news_or_mail_8bits = is_8bits_required ;
+     else
+ 	    news_or_mail_8bits = required_8bits ;
      *(p = tmp) = '\0';
      rfc822_header_line(&p, field, header ? header->env : NULL,
! (news_or_mail_8bits ?
! (char *)rfc1522_decode((unsigned char *) tmp_20k_buf, text, NULL) :
! 			rfc1522_encode(tmp_20k_buf, (unsigned char *) text,
! 				      ps_global->VAR_CHAR_SET) )
! 	);
      return(((writehdr && f) ? (*f)(s, tmp) : 1)
           && ((localcopy && local_so
  	     && !local_written) ? so_puts(local_so,tmp) : 1));
***************
*** 5630,5637 ****
--- 5656,5673 ----

  	switch (body->encoding) {	/* all else needs filtering */
  	  case ENC8BIT:			/* encode 8BIT into QUOTED-PRINTABLE */
+ /*	dimakop commented out
  	    if(!(sending_stream && sending_stream->ok_8bitmime))
  	      gf_link_filter(gf_8bit_qp);
+ */
+ 	if (post_or_mail==1) {	/* news posting */
+ 	    if(!(sending_stream && sending_stream->ok_8bitmime) )
+ 	      gf_link_filter(gf_8bit_qp);
+ 	} else {	/* mail posting */
+ 	    if( !required_8bits )
+ 	      gf_link_filter(gf_8bit_qp);
+ 		required_8bits = (F_ON(F_ENABLE_8BIT, ps_global));
+ 	}

  	    break;

***************
*** 5690,5697 ****
        sprintf (*dst += strlen (*dst),"Content-Transfer-Encoding: %s\015\012",
  	       body_encodings[body->encoding == ENCBINARY ? ENCBASE64 :
  			      body->encoding == ENC8BIT
! 			        ? (!(sending_stream
! 				     && sending_stream->ok_8bitmime))
  				     ? ENCQUOTEDPRINTABLE : ENC8BIT :
  			      body->encoding <= ENCMAX ? body->encoding :
  							 ENCOTHER]);
--- 5726,5732 ----
        sprintf (*dst += strlen (*dst),"Content-Transfer-Encoding: %s\015\012",
  	       body_encodings[body->encoding == ENCBINARY ? ENCBASE64 :
  			      body->encoding == ENC8BIT
! 			        ? ( !(encoding8_kind()) )
  				     ? ENCQUOTEDPRINTABLE : ENC8BIT :
  			      body->encoding <= ENCMAX ? body->encoding :
  							 ENCOTHER]);
***************
*** 6365,6368 ****
--- 6400,6442 ----
      fclose(p->ofilep);
      p->ofilep = NULL;
      (void) close_system_pipe(&p);
+ }
+
+ /* This function is to return 1 if 8 bit chars can pass without been encoded
+  * in MIME. Unfortunately the functions which handle MIME/8 bit encoding (which
+  * are pine_rfc822*) are used both when news posting and when normal email is
+  * requested. Therefore I had to set up a complicated set of flags which keep
+  * track of if 8 bits encoding is required for news or for mailing.
+  *
+  *	required_8bits is set when 8 bits are required for normal mailing.
+  *
+  * For the case that news posting is necessary then the flag is already there
+  * and that is sending_stream->ok_8bitmime.
+  * Also to distinguish if posting or mailing is taking place flag
+  *
+  *	post_or_mail
+  *
+  * is used.
+  * The criterio for the distinction is that for the mail function call_mailer()
+  * is called and for the news posting function news_poster() is used.
+  *
+  * We should mention that these flags are used both for the functions that
+  * encode the Subject (pine_header_line()) and for the functions that encode
+  * the body.
+  */
+
+ encoding8_kind()
+ {
+     int ret, needs_8bits;
+
+     if ( sending_stream && sending_stream->ok_8bitmime )
+ 		needs_8bits = 1;
+     else	needs_8bits = 0;		/* from news */
+
+     if ( post_or_mail==1 )	/* posting */
+ 	    ret = needs_8bits ;
+     else
+ 	    ret = required_8bits ;
+
+     return(ret);
  }