Fossil SCM
Avoided a crash in Fossil > Admin > Notification > Send Announcement triggered when no subscribers are set up, causing it to fail on Submit if you tell it to send the announcement to all subscribers. The check also guards against sending such things before email alerts are set up. In either case, the "Send Announcmeent" page gives an error pointing you to the docs, rather than a form that cannot be successfully submitted.
Commit
ea646955f16f82a9823f6b57a7f2ecc622647e0dc15691c341c09a24ffa74c8a
Parent
f6502e8caec3e7a…
1 file changed
+8
-2
+8
-2
| --- src/alerts.c | ||
| +++ src/alerts.c | ||
| @@ -2701,12 +2701,11 @@ | ||
| 2701 | 2701 | if( fossil_strcmp(P("name"),"test1")==0 ){ |
| 2702 | 2702 | /* Visit the /announce/test1 page to see the CGI variables */ |
| 2703 | 2703 | @ <p style='border: 1px solid black; padding: 1ex;'> |
| 2704 | 2704 | cgi_print_all(0, 0); |
| 2705 | 2705 | @ </p> |
| 2706 | - }else | |
| 2707 | - if( P("submit")!=0 && cgi_csrf_safe(1) ){ | |
| 2706 | + }else if( P("submit")!=0 && cgi_csrf_safe(1) ){ | |
| 2708 | 2707 | char *zErr = alert_send_announcement(); |
| 2709 | 2708 | style_header("Announcement Sent"); |
| 2710 | 2709 | if( zErr ){ |
| 2711 | 2710 | @ <h1>Internal Error</h1> |
| 2712 | 2711 | @ <p>The following error was reported by the system: |
| @@ -2716,11 +2715,18 @@ | ||
| 2716 | 2715 | }else{ |
| 2717 | 2716 | @ <p>The announcement has been sent.</p> |
| 2718 | 2717 | } |
| 2719 | 2718 | style_footer(); |
| 2720 | 2719 | return; |
| 2720 | + } else if( !alert_enabled() ){ | |
| 2721 | + style_header("Cannot Send Announcement"); | |
| 2722 | + @ <p>Either you have no subscribers yet, or email alerts are not yet | |
| 2723 | + @ <a href="https://fossil-scm.org/fossil/doc/trunk/www/alerts.md">set up</a> | |
| 2724 | + @ for this repository.</p> | |
| 2725 | + return; | |
| 2721 | 2726 | } |
| 2727 | + | |
| 2722 | 2728 | style_header("Send Announcement"); |
| 2723 | 2729 | @ <form method="POST"> |
| 2724 | 2730 | @ <table class="subscribe"> |
| 2725 | 2731 | if( g.perm.Admin ){ |
| 2726 | 2732 | int aa = PB("aa"); |
| 2727 | 2733 |
| --- src/alerts.c | |
| +++ src/alerts.c | |
| @@ -2701,12 +2701,11 @@ | |
| 2701 | if( fossil_strcmp(P("name"),"test1")==0 ){ |
| 2702 | /* Visit the /announce/test1 page to see the CGI variables */ |
| 2703 | @ <p style='border: 1px solid black; padding: 1ex;'> |
| 2704 | cgi_print_all(0, 0); |
| 2705 | @ </p> |
| 2706 | }else |
| 2707 | if( P("submit")!=0 && cgi_csrf_safe(1) ){ |
| 2708 | char *zErr = alert_send_announcement(); |
| 2709 | style_header("Announcement Sent"); |
| 2710 | if( zErr ){ |
| 2711 | @ <h1>Internal Error</h1> |
| 2712 | @ <p>The following error was reported by the system: |
| @@ -2716,11 +2715,18 @@ | |
| 2716 | }else{ |
| 2717 | @ <p>The announcement has been sent.</p> |
| 2718 | } |
| 2719 | style_footer(); |
| 2720 | return; |
| 2721 | } |
| 2722 | style_header("Send Announcement"); |
| 2723 | @ <form method="POST"> |
| 2724 | @ <table class="subscribe"> |
| 2725 | if( g.perm.Admin ){ |
| 2726 | int aa = PB("aa"); |
| 2727 |
| --- src/alerts.c | |
| +++ src/alerts.c | |
| @@ -2701,12 +2701,11 @@ | |
| 2701 | if( fossil_strcmp(P("name"),"test1")==0 ){ |
| 2702 | /* Visit the /announce/test1 page to see the CGI variables */ |
| 2703 | @ <p style='border: 1px solid black; padding: 1ex;'> |
| 2704 | cgi_print_all(0, 0); |
| 2705 | @ </p> |
| 2706 | }else if( P("submit")!=0 && cgi_csrf_safe(1) ){ |
| 2707 | char *zErr = alert_send_announcement(); |
| 2708 | style_header("Announcement Sent"); |
| 2709 | if( zErr ){ |
| 2710 | @ <h1>Internal Error</h1> |
| 2711 | @ <p>The following error was reported by the system: |
| @@ -2716,11 +2715,18 @@ | |
| 2715 | }else{ |
| 2716 | @ <p>The announcement has been sent.</p> |
| 2717 | } |
| 2718 | style_footer(); |
| 2719 | return; |
| 2720 | } else if( !alert_enabled() ){ |
| 2721 | style_header("Cannot Send Announcement"); |
| 2722 | @ <p>Either you have no subscribers yet, or email alerts are not yet |
| 2723 | @ <a href="https://fossil-scm.org/fossil/doc/trunk/www/alerts.md">set up</a> |
| 2724 | @ for this repository.</p> |
| 2725 | return; |
| 2726 | } |
| 2727 | |
| 2728 | style_header("Send Announcement"); |
| 2729 | @ <form method="POST"> |
| 2730 | @ <table class="subscribe"> |
| 2731 | if( g.perm.Admin ){ |
| 2732 | int aa = PB("aa"); |
| 2733 |