33
33
#include "maptime.h"
34
34
#include "mapows.h"
35
35
36
+ #include "cpl_conv.h"
37
+
36
38
/*
37
39
** Enumerated types, keep the query modes in sequence and at the end of the enumeration (mode enumeration is in maptemplate.h).
38
40
*/
@@ -197,12 +199,15 @@ mapObj *msCGILoadMap(mapservObj *mapserv)
197
199
int i , j ;
198
200
mapObj * map = NULL ;
199
201
202
+ const char * ms_mapfile = CPLGetConfigOption ("MS_MAPFILE" , NULL );
203
+ const char * ms_map_no_path = CPLGetConfigOption ("MS_MAP_NO_PATH" , NULL );
204
+ const char * ms_map_pattern = CPLGetConfigOption ("MS_MAP_PATTERN" , NULL );
205
+
200
206
for (i = 0 ; i < mapserv -> request -> NumParams ; i ++ ) /* find the mapfile parameter first */
201
207
if (strcasecmp (mapserv -> request -> ParamNames [i ], "map" ) == 0 ) break ;
202
208
203
209
if (i == mapserv -> request -> NumParams ) {
204
- char * ms_mapfile = getenv ("MS_MAPFILE" );
205
- if (ms_mapfile ) {
210
+ if (ms_mapfile != NULL ) {
206
211
map = msLoadMap (ms_mapfile ,NULL );
207
212
} else {
208
213
msSetError (MS_WEBERR , "CGI variable \"map\" is not set." , "msCGILoadMap()" ); /* no default, outta here */
@@ -213,12 +218,12 @@ mapObj *msCGILoadMap(mapservObj *mapserv)
213
218
map = msLoadMap (getenv (mapserv -> request -> ParamValues [i ]), NULL );
214
219
else {
215
220
/* by here we know the request isn't for something in an environment variable */
216
- if (getenv ( "MS_MAP_NO_PATH" ) ) {
221
+ if (ms_map_no_path != NULL ) {
217
222
msSetError (MS_WEBERR , "Mapfile not found in environment variables and this server is not configured for full paths." , "msCGILoadMap()" );
218
223
return NULL ;
219
224
}
220
225
221
- if (getenv ( "MS_MAP_PATTERN" ) && msEvalRegex (getenv ( "MS_MAP_PATTERN" ) , mapserv -> request -> ParamValues [i ]) != MS_TRUE ) {
226
+ if (ms_map_pattern != NULL && msEvalRegex (ms_map_pattern , mapserv -> request -> ParamValues [i ]) != MS_TRUE ) {
222
227
msSetError (MS_WEBERR , "Parameter 'map' value fails to validate." , "msCGILoadMap()" );
223
228
return NULL ;
224
229
}
0 commit comments