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.

wyoung 2018-10-04 07:36 trunk
Commit ea646955f16f82a9823f6b57a7f2ecc622647e0dc15691c341c09a24ffa74c8a
1 file changed +8 -2
+8 -2
--- src/alerts.c
+++ src/alerts.c
@@ -2701,12 +2701,11 @@
27012701
if( fossil_strcmp(P("name"),"test1")==0 ){
27022702
/* Visit the /announce/test1 page to see the CGI variables */
27032703
@ <p style='border: 1px solid black; padding: 1ex;'>
27042704
cgi_print_all(0, 0);
27052705
@ </p>
2706
- }else
2707
- if( P("submit")!=0 && cgi_csrf_safe(1) ){
2706
+ }else if( P("submit")!=0 && cgi_csrf_safe(1) ){
27082707
char *zErr = alert_send_announcement();
27092708
style_header("Announcement Sent");
27102709
if( zErr ){
27112710
@ <h1>Internal Error</h1>
27122711
@ <p>The following error was reported by the system:
@@ -2716,11 +2715,18 @@
27162715
}else{
27172716
@ <p>The announcement has been sent.</p>
27182717
}
27192718
style_footer();
27202719
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;
27212726
}
2727
+
27222728
style_header("Send Announcement");
27232729
@ <form method="POST">
27242730
@ <table class="subscribe">
27252731
if( g.perm.Admin ){
27262732
int aa = PB("aa");
27272733
--- 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

Keyboard Shortcuts

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