Fossil SCM

Make sure the content of outbound email messages always ends with a newline.

drh 2018-06-22 12:25 UTC email-alerts
Commit b70034837382b06e4b35026b5e6c65248b7ba8027f6154222d37c765088de45d
2 files changed +10 +3
+10
--- src/blob.c
+++ src/blob.c
@@ -653,10 +653,20 @@
653653
if( pTo ){
654654
blob_append(pTo, &pFrom->aData[pFrom->iCursor], i - pFrom->iCursor);
655655
}
656656
pFrom->iCursor = i;
657657
}
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
+}
658668
659669
/*
660670
** Return true if the blob contains a valid base16 identifier artifact hash.
661671
**
662672
** The value returned is actually one of HNAME_SHA1 OR HNAME_K256 if the
663673
--- src/blob.c
+++ src/blob.c
@@ -653,10 +653,20 @@
653 if( pTo ){
654 blob_append(pTo, &pFrom->aData[pFrom->iCursor], i - pFrom->iCursor);
655 }
656 pFrom->iCursor = i;
657 }
 
 
 
 
 
 
 
 
 
 
658
659 /*
660 ** Return true if the blob contains a valid base16 identifier artifact hash.
661 **
662 ** The value returned is actually one of HNAME_SHA1 OR HNAME_K256 if the
663
--- src/blob.c
+++ src/blob.c
@@ -653,10 +653,20 @@
653 if( pTo ){
654 blob_append(pTo, &pFrom->aData[pFrom->iCursor], i - pFrom->iCursor);
655 }
656 pFrom->iCursor = i;
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 }
668
669 /*
670 ** Return true if the blob contains a valid base16 identifier artifact hash.
671 **
672 ** The value returned is actually one of HNAME_SHA1 OR HNAME_K256 if the
673
--- src/email.c
+++ src/email.c
@@ -307,18 +307,20 @@
307307
zBoundary = db_text(0, "SELECT hex(randomblob(20))");
308308
blob_appendf(&all, "Content-Type: multipart/alternative;"
309309
" boundary=\"%s\"\r\n", zBoundary);
310310
}
311311
if( pPlain ){
312
+ blob_add_final_newline(pPlain);
312313
if( zBoundary ){
313314
blob_appendf(&all, "\r\n--%s\r\n", zBoundary);
314315
}
315316
blob_appendf(&all,"Content-Type: text/plain\r\n");
316317
blob_appendf(&all, "Content-Transfer-Encoding: base64\r\n\r\n");
317318
append_base64(&all, pPlain);
318319
}
319320
if( pHtml ){
321
+ blob_add_final_newline(pHtml);
320322
if( zBoundary ){
321323
blob_appendf(&all, "--%s\r\n", zBoundary);
322324
}
323325
blob_appendf(&all,"Content-Type: text/html\r\n");
324326
blob_appendf(&all, "Content-Transfer-Encoding: base64\r\n\r\n");
@@ -524,10 +526,11 @@
524526
if( zSource ){
525527
blob_read_from_file(&body, zSource, ExtFILE);
526528
}else{
527529
prompt_for_user_comment(&body, &prompt);
528530
}
531
+ blob_add_final_newline(&body);
529532
if( sendAsHtml ){
530533
email_send(&hdr, 0, &body, zDest);
531534
}else if( sendAsBoth ){
532535
Blob html;
533536
blob_init(&html, 0, 0);
534537
--- src/email.c
+++ src/email.c
@@ -307,18 +307,20 @@
307 zBoundary = db_text(0, "SELECT hex(randomblob(20))");
308 blob_appendf(&all, "Content-Type: multipart/alternative;"
309 " boundary=\"%s\"\r\n", zBoundary);
310 }
311 if( pPlain ){
 
312 if( zBoundary ){
313 blob_appendf(&all, "\r\n--%s\r\n", zBoundary);
314 }
315 blob_appendf(&all,"Content-Type: text/plain\r\n");
316 blob_appendf(&all, "Content-Transfer-Encoding: base64\r\n\r\n");
317 append_base64(&all, pPlain);
318 }
319 if( pHtml ){
 
320 if( zBoundary ){
321 blob_appendf(&all, "--%s\r\n", zBoundary);
322 }
323 blob_appendf(&all,"Content-Type: text/html\r\n");
324 blob_appendf(&all, "Content-Transfer-Encoding: base64\r\n\r\n");
@@ -524,10 +526,11 @@
524 if( zSource ){
525 blob_read_from_file(&body, zSource, ExtFILE);
526 }else{
527 prompt_for_user_comment(&body, &prompt);
528 }
 
529 if( sendAsHtml ){
530 email_send(&hdr, 0, &body, zDest);
531 }else if( sendAsBoth ){
532 Blob html;
533 blob_init(&html, 0, 0);
534
--- src/email.c
+++ src/email.c
@@ -307,18 +307,20 @@
307 zBoundary = db_text(0, "SELECT hex(randomblob(20))");
308 blob_appendf(&all, "Content-Type: multipart/alternative;"
309 " boundary=\"%s\"\r\n", zBoundary);
310 }
311 if( pPlain ){
312 blob_add_final_newline(pPlain);
313 if( zBoundary ){
314 blob_appendf(&all, "\r\n--%s\r\n", zBoundary);
315 }
316 blob_appendf(&all,"Content-Type: text/plain\r\n");
317 blob_appendf(&all, "Content-Transfer-Encoding: base64\r\n\r\n");
318 append_base64(&all, pPlain);
319 }
320 if( pHtml ){
321 blob_add_final_newline(pHtml);
322 if( zBoundary ){
323 blob_appendf(&all, "--%s\r\n", zBoundary);
324 }
325 blob_appendf(&all,"Content-Type: text/html\r\n");
326 blob_appendf(&all, "Content-Transfer-Encoding: base64\r\n\r\n");
@@ -524,10 +526,11 @@
526 if( zSource ){
527 blob_read_from_file(&body, zSource, ExtFILE);
528 }else{
529 prompt_for_user_comment(&body, &prompt);
530 }
531 blob_add_final_newline(&body);
532 if( sendAsHtml ){
533 email_send(&hdr, 0, &body, zDest);
534 }else if( sendAsBoth ){
535 Blob html;
536 blob_init(&html, 0, 0);
537

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button