Fossil SCM
Make sure the content of outbound email messages always ends with a newline.
Commit
b70034837382b06e4b35026b5e6c65248b7ba8027f6154222d37c765088de45d
Parent
f9116088243353b…
2 files changed
+10
+3
+10
| --- src/blob.c | ||
| +++ src/blob.c | ||
| @@ -653,10 +653,20 @@ | ||
| 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 |
| --- 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 |
+3
| --- src/email.c | ||
| +++ src/email.c | ||
| @@ -307,18 +307,20 @@ | ||
| 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"); |
| @@ -524,10 +526,11 @@ | ||
| 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 |
| --- 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 |