Skip to content

Commit fc78b78

Browse files
committed
Stop swallowing all errors to show index page
1 parent 64a199d commit fc78b78

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

src/apps/mapserv.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "mapserver-config.h"
3535
#include <stdbool.h>
3636
#include <stdlib.h>
37+
#include <string.h>
3738

3839
#ifdef USE_FASTCGI
3940
#define NO_FCGI_DEFINES
@@ -341,8 +342,24 @@ int main(int argc, char *argv[]) {
341342
if (ms_index_dir != NULL) {
342343
// Try normal dispatch first
343344
if (msCGIDispatchRequest(mapserv) != MS_SUCCESS) {
344-
// Fallback to landing page
345-
if (msCGIDispatchMapIndexRequest(mapserv, config) != MS_SUCCESS) {
345+
errorObj *ms_error = msGetErrorObj();
346+
int show_index = MS_FALSE;
347+
if (mapserv->request->NumParams == 0) {
348+
show_index = MS_TRUE;
349+
} else if (ms_error != NULL && ms_error->code == MS_WEBERR) {
350+
if (strstr(ms_error->message, "No query information to decode") !=
351+
NULL ||
352+
strstr(ms_error->message,
353+
"Traditional BROWSE mode requires a TEMPLATE") !=
354+
NULL) {
355+
// Fallback to landing page
356+
show_index = MS_TRUE;
357+
}
358+
}
359+
360+
if (show_index &&
361+
msCGIDispatchMapIndexRequest(mapserv, config) == MS_SUCCESS) {
362+
} else {
346363
msCGIWriteError(mapserv);
347364
goto end_request;
348365
}

0 commit comments

Comments
 (0)