Fossil SCM

Any call to fossil_fatal() while generating a webpage changes the output to a 400 Bad Request with an appropriately formatted web page.

drh 2018-06-24 23:17 UTC trunk
Commit a0863d2b46174995a79f0f8e1c4c0fbf51020513d74152ece711e5b9fb0130d6
2 files changed +1 -1 +10 -4
+1 -1
--- src/main.c
+++ src/main.c
@@ -162,11 +162,11 @@
162162
const char *zContentType; /* The content type of the input HTTP request */
163163
int iErrPriority; /* Priority of current error message */
164164
char *zErrMsg; /* Text of an error message */
165165
int sslNotAvailable; /* SSL is not available. Do not redirect to https: */
166166
Blob cgiIn; /* Input to an xfer www method */
167
- int cgiOutput; /* Write error and status messages to CGI */
167
+ int cgiOutput; /* 0: command-line 1: CGI. 2: CGI after an error */
168168
int xferPanic; /* Write error messages in XFER protocol */
169169
int fullHttpReply; /* True for full HTTP reply. False for CGI reply */
170170
Th_Interp *interp; /* The TH1 interpreter */
171171
char *th1Setup; /* The TH1 post-creation setup script, if any */
172172
int th1Flags; /* The TH1 integration state flags */
173173
--- src/main.c
+++ src/main.c
@@ -162,11 +162,11 @@
162 const char *zContentType; /* The content type of the input HTTP request */
163 int iErrPriority; /* Priority of current error message */
164 char *zErrMsg; /* Text of an error message */
165 int sslNotAvailable; /* SSL is not available. Do not redirect to https: */
166 Blob cgiIn; /* Input to an xfer www method */
167 int cgiOutput; /* Write error and status messages to CGI */
168 int xferPanic; /* Write error messages in XFER protocol */
169 int fullHttpReply; /* True for full HTTP reply. False for CGI reply */
170 Th_Interp *interp; /* The TH1 interpreter */
171 char *th1Setup; /* The TH1 post-creation setup script, if any */
172 int th1Flags; /* The TH1 integration state flags */
173
--- src/main.c
+++ src/main.c
@@ -162,11 +162,11 @@
162 const char *zContentType; /* The content type of the input HTTP request */
163 int iErrPriority; /* Priority of current error message */
164 char *zErrMsg; /* Text of an error message */
165 int sslNotAvailable; /* SSL is not available. Do not redirect to https: */
166 Blob cgiIn; /* Input to an xfer www method */
167 int cgiOutput; /* 0: command-line 1: CGI. 2: CGI after an error */
168 int xferPanic; /* Write error messages in XFER protocol */
169 int fullHttpReply; /* True for full HTTP reply. False for CGI reply */
170 Th_Interp *interp; /* The TH1 interpreter */
171 char *th1Setup; /* The TH1 post-creation setup script, if any */
172 int th1Flags; /* The TH1 integration state flags */
173
+10 -4
--- src/printf.c
+++ src/printf.c
@@ -1056,10 +1056,11 @@
10561056
else
10571057
#endif
10581058
{
10591059
if( g.cgiOutput ){
10601060
cgi_printf("<p class=\"generalError\">%h</p>", z);
1061
+ cgi_set_status(500, "Internal Server Error");
10611062
cgi_reply();
10621063
}else if( !g.fQuiet ){
10631064
fossil_force_newline();
10641065
fossil_puts("Fossil internal error: ", 1);
10651066
fossil_puts(z, 1);
@@ -1086,20 +1087,24 @@
10861087
}
10871088
}
10881089
else
10891090
#endif
10901091
{
1091
- if( g.cgiOutput ){
1092
- g.cgiOutput = 0;
1093
- cgi_printf("<p class=\"generalError\">\n%h\n</p>\n", z);
1092
+ if( g.cgiOutput==1 ){
1093
+ g.cgiOutput = 2;
1094
+ cgi_reset_content();
1095
+ style_header("Bad Request");
1096
+ @ <p class="generalError">%h(z)</p>
1097
+ cgi_set_status(400, "Bad Request");
1098
+ style_footer();
10941099
cgi_reply();
10951100
}else if( !g.fQuiet ){
10961101
fossil_force_newline();
10971102
fossil_trace("%s\n", z);
10981103
}
10991104
}
1100
- free(z);
1105
+ fossil_free(z);
11011106
db_force_rollback();
11021107
fossil_exit(rc);
11031108
}
11041109
11051110
/* This routine works like fossil_fatal() except that if called
@@ -1131,10 +1136,11 @@
11311136
#endif
11321137
{
11331138
if( g.cgiOutput ){
11341139
g.cgiOutput = 0;
11351140
cgi_printf("<p class=\"generalError\">\n%h\n</p>\n", z);
1141
+ cgi_set_status(400, "Bad Request");
11361142
cgi_reply();
11371143
}else{
11381144
fossil_force_newline();
11391145
fossil_trace("%s\n", z);
11401146
}
11411147
--- src/printf.c
+++ src/printf.c
@@ -1056,10 +1056,11 @@
1056 else
1057 #endif
1058 {
1059 if( g.cgiOutput ){
1060 cgi_printf("<p class=\"generalError\">%h</p>", z);
 
1061 cgi_reply();
1062 }else if( !g.fQuiet ){
1063 fossil_force_newline();
1064 fossil_puts("Fossil internal error: ", 1);
1065 fossil_puts(z, 1);
@@ -1086,20 +1087,24 @@
1086 }
1087 }
1088 else
1089 #endif
1090 {
1091 if( g.cgiOutput ){
1092 g.cgiOutput = 0;
1093 cgi_printf("<p class=\"generalError\">\n%h\n</p>\n", z);
 
 
 
 
1094 cgi_reply();
1095 }else if( !g.fQuiet ){
1096 fossil_force_newline();
1097 fossil_trace("%s\n", z);
1098 }
1099 }
1100 free(z);
1101 db_force_rollback();
1102 fossil_exit(rc);
1103 }
1104
1105 /* This routine works like fossil_fatal() except that if called
@@ -1131,10 +1136,11 @@
1131 #endif
1132 {
1133 if( g.cgiOutput ){
1134 g.cgiOutput = 0;
1135 cgi_printf("<p class=\"generalError\">\n%h\n</p>\n", z);
 
1136 cgi_reply();
1137 }else{
1138 fossil_force_newline();
1139 fossil_trace("%s\n", z);
1140 }
1141
--- src/printf.c
+++ src/printf.c
@@ -1056,10 +1056,11 @@
1056 else
1057 #endif
1058 {
1059 if( g.cgiOutput ){
1060 cgi_printf("<p class=\"generalError\">%h</p>", z);
1061 cgi_set_status(500, "Internal Server Error");
1062 cgi_reply();
1063 }else if( !g.fQuiet ){
1064 fossil_force_newline();
1065 fossil_puts("Fossil internal error: ", 1);
1066 fossil_puts(z, 1);
@@ -1086,20 +1087,24 @@
1087 }
1088 }
1089 else
1090 #endif
1091 {
1092 if( g.cgiOutput==1 ){
1093 g.cgiOutput = 2;
1094 cgi_reset_content();
1095 style_header("Bad Request");
1096 @ <p class="generalError">%h(z)</p>
1097 cgi_set_status(400, "Bad Request");
1098 style_footer();
1099 cgi_reply();
1100 }else if( !g.fQuiet ){
1101 fossil_force_newline();
1102 fossil_trace("%s\n", z);
1103 }
1104 }
1105 fossil_free(z);
1106 db_force_rollback();
1107 fossil_exit(rc);
1108 }
1109
1110 /* This routine works like fossil_fatal() except that if called
@@ -1131,10 +1136,11 @@
1136 #endif
1137 {
1138 if( g.cgiOutput ){
1139 g.cgiOutput = 0;
1140 cgi_printf("<p class=\"generalError\">\n%h\n</p>\n", z);
1141 cgi_set_status(400, "Bad Request");
1142 cgi_reply();
1143 }else{
1144 fossil_force_newline();
1145 fossil_trace("%s\n", z);
1146 }
1147

Keyboard Shortcuts

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