Changeset 8828


Ignore:
Timestamp:
Mar 25, 2009 9:37:57 PM (7 years ago)
Author:
sdlime
Message:

RFC56 support.

Location:
branches/branch-4-10/mapserver
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/branch-4-10/mapserver/map.h

    r6682 r8828  
    138138#ifndef SWIG
    139139#define MS_DEFAULT_MAPFILE_PATTERN "\\.map$"
    140 #define MS_TEMPLATE_EXPR "\\.(jsp|asp|cfm|xml|wml|html|htm|shtml|phtml|php|svg)$"
     140
     141#define MS_TEMPLATE_MAGIC_STRING "MapServer Template"
     142#define MS_TEMPLATE_EXPR "\\.(xml|wml|html|htm|svg|kml|gml|js|tmpl)$"
    141143
    142144#define MS_INDEX_EXTENSION ".qix"
     
    13781380MS_DLL_EXPORT char *msHashString(const char *pszStr);
    13791381MS_DLL_EXPORT char *msCommifyString(char *str);
     1382MS_DLL_EXPORT const char *msCaseFindSubstring(const char *haystack, const char *needle);
    13801383
    13811384#ifdef NEED_STRDUP
  • branches/branch-4-10/mapserver/mapserv.c

    r8823 r8828  
    281281    if(getenv(msObj->request->ParamValues[i])) /* an environment references the actual file to use */
    282282      map = msLoadMap(getenv(msObj->request->ParamValues[i]), NULL);
    283     else
     283    else {
     284      /* by here we know the request isn't for something in an environment variable */
     285      if(getenv("MS_MAP_NO_PATH")) {
     286        msSetError(MS_WEBERR, "Mapfile not found in environment variables and this server is not configured for full paths.", "loadMap()");
     287        writeError();
     288      }
     289
     290      if(getenv("MS_MAP_PATTERN") && msEvalRegex(getenv("MS_MAP_PATTERN"), msObj->request->ParamValues[i]) != MS_TRUE) {
     291        msSetError(MS_WEBERR, "Parameter 'map' value fails to validate.", "loadMap()");
     292        writeError();
     293      }
     294
     295      /* ok to try to load now */
    284296      map = msLoadMap(msObj->request->ParamValues[i], NULL);
     297    }
    285298  }
    286299
  • branches/branch-4-10/mapserver/mapstring.c

    r5599 r8828  
    934934  return str;
    935935}
     936
     937/************************************************************************/
     938/*                  case incensitive equivalent of strstr               */
     939/************************************************************************/
     940const char *msCaseFindSubstring(const char *haystack, const char *needle)
     941{
     942  if ( !*needle )
     943    {
     944      return haystack;
     945    }
     946  for ( ; *haystack; ++haystack )
     947    {
     948      if ( toupper(*haystack) == toupper(*needle) )
     949        {
     950          /*          * Matched starting char -- loop through remaining chars.          */
     951          const char *h, *n;
     952          for ( h = haystack, n = needle; *h && *n; ++h, ++n )
     953            {
     954              if ( toupper(*h) != toupper(*n) )
     955                {
     956                  break;
     957                }
     958            }
     959          if ( !*n ) /* matched all of 'needle' to null termination */
     960            {
     961              return haystack; /* return the start of the match */
     962            }
     963        }
     964    }
     965  return 0;
     966}
  • branches/branch-4-10/mapserver/maptemplate.c

    r8823 r8828  
    137137char *processLine(mapservObj* msObj, char* instr, int mode);
    138138
     139static int isValidTemplate(FILE *stream, const char *filename)
     140{
     141  char buffer[MS_BUFFER_LENGTH];
     142
     143  if(fgets(buffer, MS_BUFFER_LENGTH, stream) != NULL) {
     144    if(!msCaseFindSubstring(buffer, MS_TEMPLATE_MAGIC_STRING)) {
     145      msSetError(MS_WEBERR, "Missing magic string, %s doesn't look like a MapServer template.", "isValidTemplate()", filename);
     146      return MS_FALSE;
     147    }
     148  }
     149
     150  return MS_TRUE;
     151}
     152
    139153/*
    140154 * Redirect to (only use in CGI)
     
    24532467        }
    24542468
     2469        if(isValidTemplate(stream, join->header) != MS_TRUE) {
     2470          fclose(stream);
     2471          return NULL;
     2472        }
     2473
    24552474        /* echo file to the output buffer, no substitutions */
    24562475        while(fgets(line, MS_BUFFER_LENGTH, stream) != NULL) outbuf = strcatalloc(outbuf, line);
     
    24622481        msSetError(MS_IOERR, "Error while opening join template file %s.", "processOneToManyJoin()", join->template);
    24632482        return(NULL);
    2464       }     
     2483      }
    24652484     
     2485      if(isValidTemplate(stream, join->header) != MS_TRUE) {
     2486        fclose(stream);
     2487        return NULL;
     2488      }
     2489
    24662490      records = MS_TRUE;
    24672491    }
     
    24782502     
    24792503    rewind(stream);
     2504    fgets(line, MS_BUFFER_LENGTH, stream); /* skip the first line since it's the magic string */
    24802505  } /* next record */
    24812506
     
    24842509      msSetError(MS_IOERR, "Error while opening join footer file %s.", "processOneToManyJoin()", join->footer);
    24852510      return(NULL);
     2511    }
     2512
     2513    if(isValidTemplate(stream, join->footer) != MS_TRUE) {
     2514      fclose(stream);
     2515      return NULL;
    24862516    }
    24872517
     
    30193049  }
    30203050
     3051  if(isValidTemplate(stream, html) != MS_TRUE) {
     3052    fclose(stream);
     3053    return MS_FAILURE;
     3054  }
     3055
    30213056  if (papszBuffer)
    30223057  {
Note: See TracChangeset for help on using the changeset viewer.