Fossil

Check-in [b7003483]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Make sure the content of outbound email messages always ends with a newline.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | email-alerts
Files: files | file ages | folders
SHA3-256: b70034837382b06e4b35026b5e6c65248b7ba8027f6154222d37c765088de45d
User & Date: drh 2018-06-22 12:25:41
Context
2018-06-22
13:50
Add the --sql option to the timeline command. check-in: d51ca5f5 user: drh tags: email-alerts
12:25
Make sure the content of outbound email messages always ends with a newline. check-in: b7003483 user: drh tags: email-alerts
03:17
Add the /unsubscribe page. check-in: f9116088 user: drh tags: email-alerts
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/blob.c.

   651    651       i++;
   652    652     }
   653    653     if( pTo ){
   654    654       blob_append(pTo, &pFrom->aData[pFrom->iCursor], i - pFrom->iCursor);
   655    655     }
   656    656     pFrom->iCursor = i;
   657    657   }
          658  +
          659  +/*
          660  +** Ensure that the text in pBlob ends with '\n'
          661  +*/
          662  +void blob_add_final_newline(Blob *pBlob){
          663  +  if( pBlob->nUsed<=0 ) return;
          664  +  if( pBlob->aData[pBlob->nUsed-1]!='\n' ){
          665  +    blob_append(pBlob, "\n", 1);
          666  +  }
          667  +}
   658    668   
   659    669   /*
   660    670   ** Return true if the blob contains a valid base16 identifier artifact hash.
   661    671   **
   662    672   ** The value returned is actually one of HNAME_SHA1 OR HNAME_K256 if the
   663    673   ** hash is valid.  Both of these are non-zero and therefore "true".
   664    674   ** If the hash is not valid, then HNAME_ERROR is returned, which is zero or

Changes to src/email.c.

   305    305     if( pPlain && pHtml ){
   306    306       blob_appendf(&all, "MIME-Version: 1.0\r\n");
   307    307       zBoundary = db_text(0, "SELECT hex(randomblob(20))");
   308    308       blob_appendf(&all, "Content-Type: multipart/alternative;"
   309    309                          " boundary=\"%s\"\r\n", zBoundary);
   310    310     }
   311    311     if( pPlain ){
          312  +    blob_add_final_newline(pPlain);
   312    313       if( zBoundary ){
   313    314         blob_appendf(&all, "\r\n--%s\r\n", zBoundary);
   314    315       }
   315    316       blob_appendf(&all,"Content-Type: text/plain\r\n");
   316    317       blob_appendf(&all, "Content-Transfer-Encoding: base64\r\n\r\n");
   317    318       append_base64(&all, pPlain);
   318    319     }
   319    320     if( pHtml ){
          321  +    blob_add_final_newline(pHtml);
   320    322       if( zBoundary ){
   321    323         blob_appendf(&all, "--%s\r\n", zBoundary);
   322    324       }
   323    325       blob_appendf(&all,"Content-Type: text/html\r\n");
   324    326       blob_appendf(&all, "Content-Transfer-Encoding: base64\r\n\r\n");
   325    327       append_base64(&all, pHtml);
   326    328     }
................................................................................
   522    524         blob_appendf(&hdr, "Subject: %s\n", zSubject);
   523    525       }
   524    526       if( zSource ){
   525    527         blob_read_from_file(&body, zSource, ExtFILE);
   526    528       }else{
   527    529         prompt_for_user_comment(&body, &prompt);
   528    530       }
          531  +    blob_add_final_newline(&body);
   529    532       if( sendAsHtml ){
   530    533         email_send(&hdr, 0, &body, zDest);
   531    534       }else if( sendAsBoth ){
   532    535         Blob html;
   533    536         blob_init(&html, 0, 0);
   534    537         blob_appendf(&html, "<pre>\n%h</pre>\n", blob_str(&body));
   535    538         email_send(&hdr, &body, &html, zDest);