diff --git a/.travis.yml b/.travis.yml index 4f8d74a844..0ac495c6f2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ before_install: - git submodule update --init --recursive - sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable - sudo apt-get update -qq - - sudo apt-get install -qq colordiff postgis libpq-dev libpng12-dev libjpeg-dev libgif-dev libgeos-dev libgd2-noxpm-dev libfreetype6-dev libfcgi-dev libcurl4-gnutls-dev libcairo2-dev libgdal1-dev libproj-dev libxml2-dev php5-dev + - sudo apt-get install -qq colordiff postgis postgresql-9.1-postgis-2.0-scripts libpq-dev libpng12-dev libjpeg-dev libgif-dev libgeos-dev libgd2-noxpm-dev libfreetype6-dev libfcgi-dev libcurl4-gnutls-dev libcairo2-dev libgdal1-dev libproj-dev libxml2-dev php5-dev - cd msautotest - ./create_postgis_test_data.sh - cd .. diff --git a/mapfile.c b/mapfile.c index 3afc20ed0f..7a23aa8064 100644 --- a/mapfile.c +++ b/mapfile.c @@ -650,7 +650,17 @@ static void writeColor(FILE *stream, int indent, const char *name, colorObj *def #if ALPHACOLOR_ENABLED msIO_fprintf(stream, "%s %d %d %d\n", name, color->red, color->green, color->blue, color->alpha); #else - msIO_fprintf(stream, "%s %d %d %d\n", name, color->red, color->green, color->blue); + if(color->alpha != 255) { + char buffer[9]; + sprintf(buffer, "%02x", color->red); + sprintf(buffer+2, "%02x", color->green); + sprintf(buffer+4, "%02x", color->blue); + sprintf(buffer+6, "%02x", color->alpha); + *(buffer+8) = 0; + msIO_fprintf(stream, "%s \"#%s\"\n", name, buffer); + } else { + msIO_fprintf(stream, "%s %d %d %d\n", name, color->red, color->green, color->blue); + } #endif } @@ -2129,7 +2139,7 @@ static void writeLabel(FILE *stream, int indent, labelObj *label) else writeNumber(stream, indent, "SIZE", -1, label->size); } - writeKeyword(stream, indent, "ALIGN", label->align, MS_ALIGN_CENTER, "CENTER", MS_ALIGN_RIGHT, "RIGHT"); + writeKeyword(stream, indent, "ALIGN", label->align, 2, MS_ALIGN_CENTER, "CENTER", MS_ALIGN_RIGHT, "RIGHT"); writeNumber(stream, indent, "BUFFER", 0, label->buffer); if(label->numbindings > 0 && label->bindings[MS_LABEL_BINDING_COLOR].item) diff --git a/mapio.c b/mapio.c index ac8cc5b26f..08612139a0 100644 --- a/mapio.c +++ b/mapio.c @@ -809,10 +809,13 @@ char *msIO_stripStdoutBufferContentType() } /* -------------------------------------------------------------------- */ - /* Copy out content type. */ + /* Copy out content type. Note we go against the coding guidelines */ + /* here and use strncpy() instead of strlcpy() as the source */ + /* buffer may not be NULL terminated - strlcpy() requires NULL */ + /* terminated sources (see issue #4672). */ /* -------------------------------------------------------------------- */ content_type = (char *) malloc(end_of_ct-14+2); - strlcpy( content_type, (const char *) buf->data + 14, end_of_ct - 14 + 2); + strncpy( content_type, (const char *) buf->data + 14, end_of_ct - 14 + 2); content_type[end_of_ct-14+1] = '\0'; /* -------------------------------------------------------------------- */ diff --git a/mapogcsld.c b/mapogcsld.c index 654175c475..1c6d5ba611 100644 --- a/mapogcsld.c +++ b/mapogcsld.c @@ -613,20 +613,20 @@ layerObj *msSLDParseSLD(mapObj *map, char *psSLDXML, int *pnLayers) } -int _msSLDParseSizeParameter(CPLXMLNode *psSize) +double _msSLDParseSizeParameter(CPLXMLNode *psSize) { - int nSize = 0; + double dSize = 0; CPLXMLNode *psLiteral = NULL; if (psSize) { psLiteral = CPLGetXMLNode(psSize, "Literal"); if (psLiteral && psLiteral->psChild && psLiteral->psChild->pszValue) - nSize = atof(psLiteral->psChild->pszValue); + dSize = atof(psLiteral->psChild->pszValue); else if (psSize->psChild && psSize->psChild->pszValue) - nSize = atof(psSize->psChild->pszValue); + dSize = atof(psSize->psChild->pszValue); } - return nSize; + return dSize; } /************************************************************************/ diff --git a/mapows.c b/mapows.c index cd30d9cd29..ce412eec19 100644 --- a/mapows.c +++ b/mapows.c @@ -95,7 +95,8 @@ static int msOWSPreParseRequest(cgiRequestObj *request, owsRequestObj *ows_request) { /* decide if KVP or XML */ - if (request->type == MS_GET_REQUEST || (request->type == MS_POST_REQUEST && strcmp(request->contenttype, "application/x-www-form-urlencoded")==0)) { + if (request->type == MS_GET_REQUEST || (request->type == MS_POST_REQUEST + && request->contenttype && strncmp(request->contenttype, "application/x-www-form-urlencoded", strlen("application/x-www-form-urlencoded")) == 0)) { int i; /* parse KVP parameters service, version and request */ for (i = 0; i < request->NumParams; ++i) { diff --git a/maprendering.c b/maprendering.c index 64f2a5b552..5a6169cb24 100644 --- a/maprendering.c +++ b/maprendering.c @@ -833,13 +833,15 @@ int msDrawMarkerSymbol(symbolSetObj *symbolset,imageObj *image, pointObj *p, sty break; } - s.style = style; computeSymbolStyle(&s,style,symbol,scalefactor,image->resolutionfactor); s.style = style; if (!s.color && !s.outlinecolor && symbol->type != MS_SYMBOL_PIXMAP && symbol->type != MS_SYMBOL_SVG) { return MS_SUCCESS; // nothing to do if no color, except for pixmap symbols } + if(s.scale == 0) { + return MS_SUCCESS; + } diff --git a/mapscript/php/php_mapscript.c b/mapscript/php/php_mapscript.c index f757d9fac6..f1bd327d0b 100644 --- a/mapscript/php/php_mapscript.c +++ b/mapscript/php/php_mapscript.c @@ -169,7 +169,7 @@ PHP_FUNCTION(ms_newMapObjFromString) map = mapObj_newFromString(string, path); if (map == NULL) { - mapscript_throw_mapserver_exception("Failed to open map file \"%s\", or map file error." TSRMLS_CC, string); + mapscript_throw_mapserver_exception("Error while loading map file from string." TSRMLS_CC); return; } diff --git a/mapserver.h b/mapserver.h index a7d9fbe15d..71ed694bcf 100644 --- a/mapserver.h +++ b/mapserver.h @@ -2052,6 +2052,7 @@ extern "C" { MS_DLL_EXPORT int msLoadSymbolSet(symbolSetObj *symbolset, mapObj *map); MS_DLL_EXPORT int msCopySymbol(symbolObj *dst, symbolObj *src, mapObj *map); MS_DLL_EXPORT int msCopySymbolSet(symbolSetObj *dst, symbolSetObj *src, mapObj *map); + MS_DLL_EXPORT int msCopyHashTable(hashTableObj *dst, hashTableObj *src); MS_DLL_EXPORT void msInitSymbolSet(symbolSetObj *symbolset); MS_DLL_EXPORT symbolObj *msGrowSymbolSet( symbolSetObj *symbolset ); MS_DLL_EXPORT int msAddImageSymbol(symbolSetObj *symbolset, char *filename); diff --git a/mapshape.c b/mapshape.c index ea0f684c78..87deafdf66 100644 --- a/mapshape.c +++ b/mapshape.c @@ -249,6 +249,10 @@ SHPHandle msSHPOpen( const char * pszLayer, const char * pszAccess ) pszFullname = (char *) msSmallMalloc(strlen(pszBasename) + 5); sprintf( pszFullname, "%s.shp", pszBasename ); psSHP->fpSHP = fopen(pszFullname, pszAccess ); + if( psSHP->fpSHP == NULL ) { + sprintf( pszFullname, "%s.SHP", pszBasename ); + psSHP->fpSHP = fopen(pszFullname, pszAccess ); + } if( psSHP->fpSHP == NULL ) { msFree(pszBasename); msFree(pszFullname); @@ -258,6 +262,10 @@ SHPHandle msSHPOpen( const char * pszLayer, const char * pszAccess ) sprintf( pszFullname, "%s.shx", pszBasename ); psSHP->fpSHX = fopen(pszFullname, pszAccess ); + if( psSHP->fpSHX == NULL ) { + sprintf( pszFullname, "%s.SHX", pszBasename ); + psSHP->fpSHX = fopen(pszFullname, pszAccess ); + } if( psSHP->fpSHX == NULL ) { msFree(pszBasename); msFree(pszFullname); @@ -1753,9 +1761,14 @@ int msShapefileWhichShapes(shapefileObj *shpfile, rectObj rect, int debug) /* deal with case where sourcename is of the form 'file.shp' */ sourcename = msStrdup(shpfile->source); - /* TODO: need to add case-insensitive handling! */ s = strstr(sourcename, ".shp"); - if( s ) *s = '\0'; + if( s ) + *s = '\0'; + else { + s = strstr(sourcename, ".SHP"); + if( s ) + *s = '\0'; + } filename = (char *)malloc(strlen(sourcename)+strlen(MS_INDEX_EXTENSION)+1); MS_CHECK_ALLOC(filename, strlen(sourcename)+strlen(MS_INDEX_EXTENSION)+1, MS_FAILURE); diff --git a/maptemplate.c b/maptemplate.c index 6b1e12b640..ef316449d0 100644 --- a/maptemplate.c +++ b/maptemplate.c @@ -2058,7 +2058,7 @@ static int processShpxyTag(layerObj *layer, char **line, shapeObj *shape) } /* build the per point format strings (version 1 contains the coordinate seperator, version 2 doesn't) */ - pointFormatLength = strlen("xh") + strlen("xf") + strlen("yh") + strlen("yf") + strlen("cs") + 10 + 1; + pointFormatLength = strlen(xh) + strlen(xf) + strlen(yh) + strlen(yf) + strlen(cs) + 12 + 1; pointFormat1 = (char *) msSmallMalloc(pointFormatLength); snprintf(pointFormat1, pointFormatLength, "%s%%.%dlf%s%s%%.%dlf%s%s", xh, precision, xf, yh, precision, yf, cs); pointFormat2 = (char *) msSmallMalloc(pointFormatLength); diff --git a/maptree.c b/maptree.c index 178fb421c9..805a554dbe 100644 --- a/maptree.c +++ b/maptree.c @@ -126,6 +126,10 @@ SHPTreeHandle msSHPDiskTreeOpen(const char * pszTree, int debug) pszFullname = (char *) msSmallMalloc(strlen(pszBasename) + 5); sprintf( pszFullname, "%s%s", pszBasename, MS_INDEX_EXTENSION); psTree->fp = fopen(pszFullname, "rb" ); + if( psTree->fp == NULL ) { + sprintf( pszFullname, "%s.QIX", pszBasename); + psTree->fp = fopen(pszFullname, "rb" ); + } msFree(pszBasename); /* don't need these any more */ msFree(pszFullname); diff --git a/mapuvraster.c b/mapuvraster.c index 6f6a04d7b6..3cc1e282dd 100644 --- a/mapuvraster.c +++ b/mapuvraster.c @@ -333,13 +333,23 @@ int msUVRASTERLayerWhichShapes(layerObj *layer, rectObj rect, int isQuery) { uvRasterLayerInfo *uvlinfo = (uvRasterLayerInfo *) layer->layerinfo; imageObj *image_tmp; - mapObj map_tmp; + outputFormatObj *outputformat = NULL; + mapObj *map_tmp; double map_cellsize; unsigned int spacing; int width, height, u_src_off, v_src_off, i, x, y; char **alteredProcessing = NULL; char **savedProcessing = NULL; + /* + ** Allocate mapObj structure + */ + map_tmp = (mapObj *)msSmallCalloc(sizeof(mapObj),1); + if(initMap(map_tmp) == -1) { /* initialize this map */ + msFree(map_tmp); + return(MS_FAILURE); + } + if (layer->debug) msDebug("Entering msUVRASTERLayerWhichShapes().\n"); @@ -358,6 +368,7 @@ int msUVRASTERLayerWhichShapes(layerObj *layer, rectObj rect, int isQuery) "msUVRASTERLayerWhichShapes()" ); return MS_FAILURE; } + /* -------------------------------------------------------------------- */ /* Determine desired spacing. Default to 32 if not otherwise set */ /* -------------------------------------------------------------------- */ @@ -371,58 +382,59 @@ int msUVRASTERLayerWhichShapes(layerObj *layer, rectObj rect, int isQuery) height = (int)ceil(layer->map->height/spacing); map_cellsize = MS_MAX(MS_CELLSIZE(rect.minx, rect.maxx,layer->map->width), MS_CELLSIZE(rect.miny,rect.maxy,layer->map->height)); - map_tmp.cellsize = map_cellsize*spacing; + map_tmp->cellsize = map_cellsize*spacing; if (layer->debug) msDebug("msUVRASTERLayerWhichShapes(): width: %d, height: %d, cellsize: %g\n", - width, height, map_tmp.cellsize); + width, height, map_tmp->cellsize); /* Initialize our dummy map */ - MS_INIT_COLOR(map_tmp.imagecolor, 255,255,255,255); - map_tmp.resolution = layer->map->resolution; - map_tmp.defresolution = layer->map->defresolution; - map_tmp.outputformat = (outputFormatObj *) msSmallCalloc(1,sizeof(outputFormatObj)); - uvlinfo->band_count = map_tmp.outputformat->bands = 2; - map_tmp.outputformat->name = NULL; - map_tmp.outputformat->driver = NULL; - map_tmp.outputformat->refcount = 0; - map_tmp.outputformat->vtable = NULL; - map_tmp.outputformat->device = NULL; - map_tmp.outputformat->renderer = MS_RENDER_WITH_RAWDATA; - map_tmp.outputformat->imagemode = MS_IMAGEMODE_FLOAT32; - - map_tmp.configoptions = layer->map->configoptions; - map_tmp.mappath = layer->map->mappath; - map_tmp.shapepath = layer->map->shapepath; - map_tmp.extent.minx = rect.minx-(0.5*map_cellsize)+(0.5*map_tmp.cellsize); - map_tmp.extent.miny = rect.miny-(0.5*map_cellsize)+(0.5*map_tmp.cellsize); - map_tmp.extent.maxx = map_tmp.extent.minx+((width-1)*map_tmp.cellsize); - map_tmp.extent.maxy = map_tmp.extent.miny+((height-1)*map_tmp.cellsize); - map_tmp.gt.rotation_angle = 0.0; - - msInitProjection(&map_tmp.projection); - msCopyProjection(&map_tmp.projection, &layer->projection); + MS_INIT_COLOR(map_tmp->imagecolor, 255,255,255,255); + map_tmp->resolution = layer->map->resolution; + map_tmp->defresolution = layer->map->defresolution; + + outputformat = (outputFormatObj *) msSmallCalloc(1,sizeof(outputFormatObj)); + outputformat->bands = uvlinfo->band_count = 2; + outputformat->name = NULL; + outputformat->driver = NULL; + outputformat->refcount = 0; + outputformat->vtable = NULL; + outputformat->device = NULL; + outputformat->renderer = MS_RENDER_WITH_RAWDATA; + outputformat->imagemode = MS_IMAGEMODE_FLOAT32; + msAppendOutputFormat(map_tmp, outputformat); + + msCopyHashTable(&map_tmp->configoptions, &layer->map->configoptions); + map_tmp->mappath = msStrdup(layer->map->mappath); + map_tmp->shapepath = msStrdup(layer->map->shapepath); + map_tmp->extent.minx = rect.minx-(0.5*map_cellsize)+(0.5*map_tmp->cellsize); + map_tmp->extent.miny = rect.miny-(0.5*map_cellsize)+(0.5*map_tmp->cellsize); + map_tmp->extent.maxx = map_tmp->extent.minx+((width-1)*map_tmp->cellsize); + map_tmp->extent.maxy = map_tmp->extent.miny+((height-1)*map_tmp->cellsize); + map_tmp->gt.rotation_angle = 0.0; + + msCopyProjection(&map_tmp->projection, &layer->projection); if (layer->debug == 5) - msDebug("msUVRASTERLayerWhichShapes(): extent: %g %d %g %g\n", - map_tmp.extent.minx, map_tmp.extent.miny, - map_tmp.extent.maxx, map_tmp.extent.maxy); + msDebug("msUVRASTERLayerWhichShapes(): extent: %g %g %g %g\n", + map_tmp->extent.minx, map_tmp->extent.miny, + map_tmp->extent.maxx, map_tmp->extent.maxy); /* important to use that function, to compute map geotransform, used by the resampling*/ - msMapSetSize(&map_tmp, width, height); + msMapSetSize(map_tmp, width, height); if (layer->debug == 5) msDebug("msUVRASTERLayerWhichShapes(): geotransform: %g %g %g %g %g %g\n", - map_tmp.gt.geotransform[0], map_tmp.gt.geotransform[1], - map_tmp.gt.geotransform[2], map_tmp.gt.geotransform[3], - map_tmp.gt.geotransform[4], map_tmp.gt.geotransform[5]); + map_tmp->gt.geotransform[0], map_tmp->gt.geotransform[1], + map_tmp->gt.geotransform[2], map_tmp->gt.geotransform[3], + map_tmp->gt.geotransform[4], map_tmp->gt.geotransform[5]); - uvlinfo->extent = map_tmp.extent; + uvlinfo->extent = map_tmp->extent; - image_tmp = msImageCreate(width, height, map_tmp.outputformat, - NULL, NULL, map_tmp.resolution, map_tmp.defresolution, - &(map_tmp.imagecolor)); + image_tmp = msImageCreate(width, height, map_tmp->outputformatlist[0], + NULL, NULL, map_tmp->resolution, map_tmp->defresolution, + &(map_tmp->imagecolor)); /* Default set to AVERAGE resampling */ if( CSLFetchNameValue( layer->processing, "RESAMPLE" ) == NULL ) { @@ -434,14 +446,16 @@ int msUVRASTERLayerWhichShapes(layerObj *layer, rectObj rect, int isQuery) layer->processing = alteredProcessing; } - if (msDrawRasterLayerLow(&map_tmp, layer, image_tmp, NULL ) == MS_FAILURE) { - msSetError(MS_MISCERR, "Unable to draw raster data.", NULL, "msUVRASTERLayerWhichShapes()" ); + if (msDrawRasterLayerLow(map_tmp, layer, image_tmp, NULL ) == MS_FAILURE) { + msSetError(MS_MISCERR, "Unable to draw raster data.", "msUVRASTERLayerWhichShapes()"); return MS_FAILURE; } /* restore the saved processing */ - if (alteredProcessing != NULL) + if (alteredProcessing != NULL) { layer->processing = savedProcessing; + CSLDestroy(alteredProcessing); + } /* free old query arrays */ if (uvlinfo->u) { @@ -484,6 +498,7 @@ int msUVRASTERLayerWhichShapes(layerObj *layer, rectObj rect, int isQuery) } msFreeImage(image_tmp); /* we do not need the imageObj anymore */ + msFreeMap(map_tmp); uvlinfo->next_shape = 0; diff --git a/mapwcs.c b/mapwcs.c index ceacabf3da..cc35463300 100644 --- a/mapwcs.c +++ b/mapwcs.c @@ -139,17 +139,18 @@ int msWCSException(mapObj *map, const char *code, const char *locator, { char *pszEncodedVal = NULL; const char *encoding; + char version_string[OWS_VERSION_MAXLEN]; if( version == NULL ) version = "1.0.0"; #if defined(USE_LIBXML2) if( msOWSParseVersionString(version) >= OWS_2_0_0 ) - return msWCSException20( map, code, locator, version ); + return msWCSException20( map, code, locator, msOWSGetVersionString(msOWSParseVersionString(version), version_string) ); #endif if( msOWSParseVersionString(version) >= OWS_1_1_0 ) - return msWCSException11( map, code, locator, version ); + return msWCSException11( map, code, locator, msOWSGetVersionString(msOWSParseVersionString(version), version_string) ); encoding = msOWSLookupMetadata(&(map->web.metadata), "CO", "encoding"); if (encoding) @@ -2162,6 +2163,13 @@ int msWCSDispatch(mapObj *map, cgiRequestObj *request, owsRequestObj *ows_reques return msWCSException(map, "InvalidParameterValue", "request", "2.0.1"); } + else if (status == MS_DONE) { + /* MS_DONE means, that the exception has already been written to the IO + buffer. + */ + msWCSFreeParamsObj20(params); + return MS_FAILURE; + } } /* check if all layer names are valid NCNames */ diff --git a/mapwcs20.c b/mapwcs20.c index 33a282d6a2..f03681ba31 100644 --- a/mapwcs20.c +++ b/mapwcs20.c @@ -667,7 +667,7 @@ static int msWCSParseRequest20_XMLDescribeCoverage( /************************************************************************/ #if defined(USE_LIBXML2) static int msWCSParseRequest20_XMLGetCoverage( - xmlNodePtr root, wcs20ParamsObjPtr params) + mapObj* map, xmlNodePtr root, wcs20ParamsObjPtr params) { xmlNodePtr child; int numIds = 0; @@ -696,6 +696,12 @@ static int msWCSParseRequest20_XMLGetCoverage( || EQUAL(content, "multipart/related"))) { params->multipart = MS_TRUE; } + else { + msSetError(MS_WCSERR, "Invalid value '%s' for parameter 'Mediatype'.", + "msWCSParseRequest20()", content); + xmlFree(content); + return MS_FAILURE; + } xmlFree(content); } else if (EQUAL((char *) child->name, "DimensionTrim")) { wcs20AxisObjPtr axis = NULL; @@ -745,7 +751,8 @@ static int msWCSParseRequest20_XMLGetCoverage( if (msWCSParseSubset20(subset, axisName, crs, min, max) == MS_FAILURE) { msWCSFreeSubsetObj20(subset); - return MS_FAILURE; + msWCSException(map, "InvalidSubsetting", "subset", "2.0.1"); + return MS_DONE; } if(NULL == (axis = msWCSFindAxis20(params, subset->axis))) { @@ -923,14 +930,14 @@ int msWCSParseRequest20(mapObj *map, if(EQUAL(params->request, "DescribeCoverage")) { ret = msWCSParseRequest20_XMLDescribeCoverage(root, params); } else if(EQUAL(params->request, "GetCoverage")) { - ret = msWCSParseRequest20_XMLGetCoverage(root, params); + ret = msWCSParseRequest20_XMLGetCoverage(map, root, params); } } return ret; #else /* defined(USE_LIBXML2) */ /* TODO: maybe with CPLXML? */ - return MS_DONE; + return MS_FAILURE; #endif /* defined(USE_LIBXML2) */ } @@ -982,6 +989,11 @@ int msWCSParseRequest20(mapObj *map, if(EQUAL(value, "multipart/mixed") || EQUAL(value, "multipart/related")) { params->multipart = MS_TRUE; } + else { + msSetError(MS_WCSERR, "Invalid value '%s' for parameter 'Mediatype'.", + "msWCSParseRequest20()", value); + return MS_FAILURE; + } } else if (EQUAL(key, "INTERPOLATION")) { params->interpolation = msStrdup(value); } else if (EQUAL(key, "OUTPUTCRS")) { @@ -1043,7 +1055,8 @@ int msWCSParseRequest20(mapObj *map, } if (msWCSParseSubsetKVPString20(subset, value) == MS_FAILURE) { msWCSFreeSubsetObj20(subset); - return MS_FAILURE; + msWCSException(map, "InvalidSubsetting", "subset", ows_request->version); + return MS_DONE; } if(NULL == (axis = msWCSFindAxis20(params, subset->axis))) { @@ -1058,7 +1071,8 @@ int msWCSParseRequest20(mapObj *map, msSetError(MS_WCSERR, "The axis '%s' is already subsetted.", "msWCSParseRequest20()", axis->name); msWCSFreeSubsetObj20(subset); - return MS_FAILURE; + msWCSException(map, "InvalidAxisLabel", "subset", ows_request->version); + return MS_DONE; } axis->subset = subset; } else if(EQUAL(key, "RANGESUBSET")) { @@ -1087,12 +1101,17 @@ int msWCSParseRequest20(mapObj *map, /************************************************************************/ static int msWCSValidateAndFindAxes20( wcs20ParamsObjPtr params, - char*** validAxisNames, - int numAxis, wcs20AxisObjPtr outAxes[]) { + static const int numAxis = 2; + char *validXAxisNames[] = {"x", "xaxis", "x-axis", "x_axis", "long", "long_axis", "long-axis", "lon", "lon_axis", "lon-axis", NULL}; + char *validYAxisNames[] = {"y", "yaxis", "y-axis", "y_axis", "lat", "lat_axis", "lat-axis", NULL}; + char **validAxisNames[2]; int iParamAxis, iAcceptedAxis, iName, i; + validAxisNames[0] = validXAxisNames; + validAxisNames[1] = validYAxisNames; + for(i = 0; i < numAxis; ++i) { outAxes[i] = NULL; } @@ -1101,20 +1120,6 @@ static int msWCSValidateAndFindAxes20( for(iParamAxis = 0; iParamAxis < params->numaxes; ++iParamAxis) { int found = 0; - /* check if subset is valid */ - if(params->axes[iParamAxis]->subset != NULL) { - if(params->axes[iParamAxis]->subset->timeOrScalar == MS_WCS20_TIME_VALUE) { - msSetError(MS_WCSERR, "Time values for subsets are not supported. ", - "msWCSCreateBoundingBox20()"); - return MS_FAILURE; - } - if(params->axes[iParamAxis]->subset->operation == MS_WCS20_SLICE) { - msSetError(MS_WCSERR, "Subset operation 'slice' is not supported.", - "msWCSCreateBoundingBox20()"); - return MS_FAILURE; - } - } - /* iterate over all given axes */ for(iAcceptedAxis = 0; iAcceptedAxis < numAxis; ++iAcceptedAxis ) { /* iterate over all possible names for the current axis */ @@ -1125,7 +1130,7 @@ static int msWCSValidateAndFindAxes20( if(outAxes[iAcceptedAxis] != NULL) { msSetError(MS_WCSERR, "The axis with the name '%s' corresponds " "to the same axis as the subset with the name '%s'.", - "msWCSValidateAndFindSubsets20()", + "msWCSValidateAndFindAxes20()", outAxes[iAcceptedAxis]->name, params->axes[iParamAxis]->name); return MS_FAILURE; } @@ -1145,7 +1150,7 @@ static int msWCSValidateAndFindAxes20( /* exit and throw error */ if(found == 0) { msSetError(MS_WCSERR, "Invalid subset axis '%s'.", - "msWCSValidateAndFindSubsets20()", params->axes[iParamAxis]->name); + "msWCSValidateAndFindAxes20()", params->axes[iParamAxis]->name); return MS_FAILURE; } } @@ -1855,6 +1860,7 @@ static int msWCSGetCoverageMetadata20(layerObj *layer, wcs20coverageMetadataObj { char *srs_uri = NULL; int i = 0; + memset(cm,0,sizeof(wcs20coverageMetadataObj)); if ( msCheckParentPointer(layer->map,"map") == MS_FAILURE ) return MS_FAILURE; @@ -2351,6 +2357,7 @@ int msWCSException20(mapObj *map, const char *exceptionCode, const char *locator, const char *version) { int size = 0; + char *status = "400 Bad Request"; char *errorString = NULL; char *errorMessage = NULL; char *schemasLocation = NULL; @@ -2417,6 +2424,18 @@ int msWCSException20(mapObj *map, const char *exceptionCode, xmlDocSetRootElement(psDoc, psRootNode); + if(EQUAL(exceptionCode, "OperationNotSupported") + || EQUAL(exceptionCode, "OptionNotSupported")) { + status = "501 Not Implemented"; + } + else if (EQUAL(exceptionCode, "NoSuchCoverage") + || EQUAL(exceptionCode, "emptyCoverageIdList") + || EQUAL(exceptionCode, "InvalidAxisLabel") + || EQUAL(exceptionCode, "InvalidSubsetting")) { + status = "404 Not Found"; + } + + msIO_setHeader("Status", "%s", status); if (encoding) msIO_setHeader("Content-Type","text/xml; charset=%s", encoding); else @@ -2957,29 +2976,10 @@ int msWCSDescribeCoverage20(mapObj *map, wcs20ParamsObjPtr params, owsRequestObj /* is found out. */ /************************************************************************/ -static int msWCSGetCoverage20_FinalizeParamsObj(wcs20ParamsObjPtr params) +static int msWCSGetCoverage20_FinalizeParamsObj(wcs20ParamsObjPtr params, wcs20AxisObjPtr *axes) { - int returnValue; - static const int numAxis = 2; - char *validXAxisNames[] = {"x", "xaxis", "x-axis", "x_axis", "long", "long_axis", "long-axis", "lon", "lon_axis", "lon-axis", NULL}; - char *validYAxisNames[] = {"y", "yaxis", "y-axis", "y_axis", "lat", "lat_axis", "lat-axis", NULL}; - char ***validAxisNames; char *crs = NULL; - wcs20AxisObjPtr *axes; - - axes = (wcs20AxisObjPtr*)msSmallMalloc(sizeof(wcs20AxisObjPtr) * numAxis); - - validAxisNames = msSmallCalloc(sizeof(char**), numAxis); - validAxisNames[0] = validXAxisNames; - validAxisNames[1] = validYAxisNames; - - returnValue = msWCSValidateAndFindAxes20(params, validAxisNames, numAxis, axes); - msFree(validAxisNames); - if(returnValue != MS_SUCCESS) { - msFree(axes); - return MS_FAILURE; - } - + if (axes[0] != NULL) { if(axes[0]->subset != NULL) { msDebug("Subset for X-axis found: %s\n", axes[0]->subset->axis); @@ -3007,7 +3007,6 @@ static int msWCSGetCoverage20_FinalizeParamsObj(wcs20ParamsObjPtr params) if(!EQUAL(crs, axes[1]->subset->crs)) { msSetError(MS_WCSERR, "CRS for axis %s and axis %s are not the same.", "msWCSCreateBoundingBox20()", axes[0]->name, axes[1]->name); - msFree(axes); return MS_FAILURE; } } else { @@ -3024,13 +3023,10 @@ static int msWCSGetCoverage20_FinalizeParamsObj(wcs20ParamsObjPtr params) msSetError(MS_WCSERR, "The units of measure of the resolution for" "axis %s and axis %s are not the same.", "msWCSCreateBoundingBox20()", axes[0]->name, axes[1]->name); - msFree(axes); return MS_FAILURE; } } - msFree(axes); - /* check if projections are equal */ if(crs != NULL) { params->subsetcrs = msStrdup(crs); @@ -3167,9 +3163,9 @@ int msWCSGetCoverage20(mapObj *map, cgiRequestObj *request, /* throw exception if no Layer was found */ if (layer == NULL) { msSetError(MS_WCSERR, - "COVERAGE=%s not found, not in supported layer list. A layer might be disabled for \ + "COVERAGEID=%s not found, not in supported layer list. A layer might be disabled for \ this request. Check wcs/ows_enable_request settings.", "msWCSGetCoverage20()", params->ids[0]); - return msWCSException(map, "InvalidParameterValue", "coverage", + return msWCSException(map, "NoSuchCoverage", "coverageid", params->version); } /* retrieve coverage metadata */ @@ -3203,9 +3199,36 @@ this request. Check wcs/ows_enable_request settings.", "msWCSGetCoverage20()", p "projection", params->version); } - if(msWCSGetCoverage20_FinalizeParamsObj(params) == MS_FAILURE) { - msWCSClearCoverageMetadata20(&cm); - return msWCSException(map, "InvalidParameterValue", "extent", params->version); + /* iterate over all subsets and check if they are valid*/ + for(i = 0; i < params->numaxes; ++i) { + if(params->axes[i]->subset != NULL) { + if(params->axes[i]->subset->timeOrScalar == MS_WCS20_TIME_VALUE) { + msSetError(MS_WCSERR, "Time values for subsets are not supported. ", + "msWCSGetCoverage20()"); + return msWCSException(map, "InvalidSubsetting", "subset", params->version); + } + if(params->axes[i]->subset->operation == MS_WCS20_SLICE) { + msSetError(MS_WCSERR, "Subset operation 'slice' is not supported.", + "msWCSGetCoverage20()"); + return msWCSException(map, "InvalidSubsetting", "subset", params->version); + } + } + } + + { + wcs20AxisObjPtr *axes; + axes = msSmallMalloc(sizeof(wcs20AxisObjPtr) * 2); + if(msWCSValidateAndFindAxes20(params, axes) == MS_FAILURE) { + msWCSClearCoverageMetadata20(&cm); + msFree(axes); + return msWCSException(map, "InvalidAxisLabel", "subset", params->version); + } + if(msWCSGetCoverage20_FinalizeParamsObj(params, axes) == MS_FAILURE) { + msWCSClearCoverageMetadata20(&cm); + msFree(axes); + return msWCSException(map, "InvalidParameterValue", "extent", params->version); + } + msFree(axes); } subsets = params->bbox; diff --git a/mapwms.c b/mapwms.c index 2b96574c9f..e96c2eddfb 100644 --- a/mapwms.c +++ b/mapwms.c @@ -2446,7 +2446,7 @@ int msDumpLayer(mapObj *map, layerObj *lp, int nVersion, const char *script_url_ break; } } - if (l < lp2->numclasses) + if (lp2 && l < lp2->numclasses) break; } if (j < numNestedGroups[lp->index]) diff --git a/mapxbase.c b/mapxbase.c index 2dfc38a3c2..a667f5b125 100644 --- a/mapxbase.c +++ b/mapxbase.c @@ -162,11 +162,11 @@ DBFHandle msDBFOpen( const char * pszFilename, const char * pszAccess ) pszDBFFilename = (char *) msSmallMalloc(strlen(pszFilename)+1); strcpy( pszDBFFilename, pszFilename ); - if( strcmp(pszFilename+strlen(pszFilename)-4,".shp") - || strcmp(pszFilename+strlen(pszFilename)-4,".shx") ) { + if( strcmp(pszFilename+strlen(pszFilename)-4,".shp") == 0 + || strcmp(pszFilename+strlen(pszFilename)-4,".shx") == 0 ) { strcpy( pszDBFFilename+strlen(pszDBFFilename)-4, ".dbf"); - } else if( strcmp(pszFilename+strlen(pszFilename)-4,".SHP") - || strcmp(pszFilename+strlen(pszFilename)-4,".SHX") ) { + } else if( strcmp(pszFilename+strlen(pszFilename)-4,".SHP") == 0 + || strcmp(pszFilename+strlen(pszFilename)-4,".SHX") == 0 ) { strcpy( pszDBFFilename+strlen(pszDBFFilename)-4, ".DBF"); } @@ -176,6 +176,13 @@ DBFHandle msDBFOpen( const char * pszFilename, const char * pszAccess ) psDBF = (DBFHandle) calloc( 1, sizeof(DBFInfo) ); MS_CHECK_ALLOC(psDBF, sizeof(DBFInfo), NULL); psDBF->fp = fopen( pszDBFFilename, pszAccess ); + if( psDBF->fp == NULL ) + { + if( strcmp(pszDBFFilename+strlen(pszDBFFilename)-4,".dbf") == 0 ) { + strcpy( pszDBFFilename+strlen(pszDBFFilename)-4, ".DBF"); + psDBF->fp = fopen( pszDBFFilename, pszAccess ); + } + } if( psDBF->fp == NULL ) return( NULL ); diff --git a/msautotest b/msautotest index fff3a03428..4fab671cc4 160000 --- a/msautotest +++ b/msautotest @@ -1 +1 @@ -Subproject commit fff3a03428314ee517cc5bf20a5e4ee897a4f51d +Subproject commit 4fab671cc435ec9b5374a95f707928cba2bfd683 diff --git a/tile4ms.c b/tile4ms.c index 445acedda3..266bf3b237 100644 --- a/tile4ms.c +++ b/tile4ms.c @@ -213,6 +213,7 @@ int process_shapefiles(char *metaFileNameP, char *tileFileNameP, /* create and add shape object. Returns link to entry in DBF file */ /* --------------------------------------------------------------- */ + shapeRect.type = MS_SHAPE_POLYGON; msAddLine(&shapeRect, &line); entityNum = msSHPWriteShape( tileSHP, &shapeRect );