[mapguide-commits] r5058 - trunk/MgDev/Web/src/HttpHandler

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Jul 27 22:50:54 EDT 2010


Author: liuar
Date: 2010-07-28 02:50:54 +0000 (Wed, 28 Jul 2010)
New Revision: 5058

Modified:
   trunk/MgDev/Web/src/HttpHandler/OgcWmsException.cpp
   trunk/MgDev/Web/src/HttpHandler/OgcWmsException.h
   trunk/MgDev/Web/src/HttpHandler/OgcWmsServer.cpp
   trunk/MgDev/Web/src/HttpHandler/OgcWmsServer.h
Log:
Ticket #1392

This submission added the validation of version parameter in GetMap and GetFeatureInfo operation. 


Modified: trunk/MgDev/Web/src/HttpHandler/OgcWmsException.cpp
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/OgcWmsException.cpp	2010-07-28 02:48:32 UTC (rev 5057)
+++ trunk/MgDev/Web/src/HttpHandler/OgcWmsException.cpp	2010-07-28 02:50:54 UTC (rev 5058)
@@ -37,6 +37,7 @@
 CPSZ MgOgcWmsException::kpszMissingBoundingBox     = _("MissingBoundingBox");
 CPSZ MgOgcWmsException::kpszInvalidBoundingBox     = _("InvalidBoundingBox");
 CPSZ MgOgcWmsException::kpszMissingInfoFormat      = _("MissingInfoFormat");
+CPSZ MgOgcWmsException::kpszMissingVersion         = _("MissingVersion");
 
 // A catch-all for the innards being really unhealthy!
 CPSZ MgOgcException::kpszInternalError          = _("InternalError");

Modified: trunk/MgDev/Web/src/HttpHandler/OgcWmsException.h
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/OgcWmsException.h	2010-07-28 02:48:32 UTC (rev 5057)
+++ trunk/MgDev/Web/src/HttpHandler/OgcWmsException.h	2010-07-28 02:50:54 UTC (rev 5058)
@@ -55,6 +55,9 @@
 OperationNotSupported Request is for an optional operation that is not supported by the
                       server.
 MissingBoundingBox    Request does not contain a required bounding box parameter.
+InvalidBoundingBox    Request contains an invalid bounding box value.
+MissingInfoFormat     Request does not contain a required info format parameter.
+MissingVersion        Request does not contain a required version parameter.
 */
 
     static CPSZ kpszInvalidFormat;
@@ -74,6 +77,7 @@
     static CPSZ kpszMissingBoundingBox;
     static CPSZ kpszInvalidBoundingBox;
     static CPSZ kpszMissingInfoFormat;
+    static CPSZ kpszMissingVersion;
 };
 
 #endif//_OgcWmsException_h

Modified: trunk/MgDev/Web/src/HttpHandler/OgcWmsServer.cpp
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/OgcWmsServer.cpp	2010-07-28 02:48:32 UTC (rev 5057)
+++ trunk/MgDev/Web/src/HttpHandler/OgcWmsServer.cpp	2010-07-28 02:50:54 UTC (rev 5058)
@@ -86,6 +86,7 @@
 CPSZ kpszExceptionMessageInvalidImageFormat   = _("The request uses an unsupported image format. (Found FORMAT=&Request.format;)"); // Localize
 CPSZ kpszExceptionMessageMissingImageFormat   = _("The request must contain a FORMAT parameter to specify the required image format."); // Localize
 CPSZ kpszExceptionMessageMissingInfoFormat    = _("The request must contain an INFO_FORMAT parameter to specify the format of feature information (MIME type)."); // Localize
+CPSZ kpszExceptionMessageMissingVersion       = _("The request must contain a VERSION parameter to specify the WMS version."); // Localize
 // END LOCALIZATION
 
 CPSZ kpszPiEnumLayers                      = _("EnumLayers");
@@ -350,37 +351,49 @@
 {
     bool bValid = true;
 
+    //  Search for a VERSION= parameter
+    STRING version = GetRequestVersion();
+    if(version.empty())
+    {
+        ServiceExceptionReportResponse(MgOgcWmsException(MgOgcWmsException::kpszMissingVersion,
+                                       kpszExceptionMessageMissingVersion));
+        bValid = false;
+    }
+
     //
     //  Search for a FORMAT= parameter, and verify that its value is supported.
     //
     CPSZ imageFormat = RequestParameter(kpszQueryStringFormat);
-    if(imageFormat != NULL && szlen(imageFormat) > 0)
+    if(bValid)
     {
-        // We're expecting a supported formats definition.  There's a hard-coded
-        // default, but the templates can also define one.
-        CPSZ pszMap = this->Definition(kpszDefineSupportedFormats);
-        if(pszMap) {
-            MgXmlParser Xml(pszMap);
-            STRING sTo;
-            if(!MapValue(Xml,imageFormat,sTo) || sTo.length() == 0) {
-                ServiceExceptionReportResponse(MgOgcWmsException(MgOgcWmsException::kpszInvalidFormat,
-                                                                 kpszExceptionMessageInvalidImageFormat));
+        if(imageFormat != NULL && szlen(imageFormat) > 0)
+        {
+            // We're expecting a supported formats definition.  There's a hard-coded
+            // default, but the templates can also define one.
+            CPSZ pszMap = this->Definition(kpszDefineSupportedFormats);
+            if(pszMap) {
+                MgXmlParser Xml(pszMap);
+                STRING sTo;
+                if(!MapValue(Xml,imageFormat,sTo) || sTo.length() == 0) {
+                    ServiceExceptionReportResponse(MgOgcWmsException(MgOgcWmsException::kpszInvalidFormat,
+                                                                     kpszExceptionMessageInvalidImageFormat));
+                    bValid = false;
+                }
+            }
+            else {
+                this->m_pTopOfDefinitions->AddDefinition(kpszDefinitionInitServerError,kpszDefineSupportedFormats);
+                InternalError(kpszInternalErrorMissingDefinition);
                 bValid = false;
             }
         }
-        else {
-            this->m_pTopOfDefinitions->AddDefinition(kpszDefinitionInitServerError,kpszDefineSupportedFormats);
-            InternalError(kpszInternalErrorMissingDefinition);
+        else
+        {
+            // The required FORMAT parameter is missing
+            ServiceExceptionReportResponse(MgOgcWmsException(MgOgcWmsException::kpszInvalidFormat,
+                                                             kpszExceptionMessageMissingImageFormat));
             bValid = false;
         }
     }
-    else
-    {
-        // The required FORMAT parameter is missing
-        ServiceExceptionReportResponse(MgOgcWmsException(MgOgcWmsException::kpszInvalidFormat,
-                                                         kpszExceptionMessageMissingImageFormat));
-        bValid = false;
-    }
 
     //
     // Look for the LAYERS= parameter and parse its value into the comma-separates list of values.
@@ -557,9 +570,8 @@
         }
         else
         {
-            STRING sVersion = RequestParameter(kpszQueryStringVersion);
             STRING sBBox(bbox);
-            if(sVersion >= _("1.3.0"))
+            if(version >= _("1.3.0"))
             {
                 CPSZ crs = RequestParameter(kpszQueryStringCrs);
                 if(crs == NULL || szlen(crs) == 0)
@@ -631,9 +643,9 @@
     if(bValid)
     {
         // INFO_FORMAT becomes a mandatory parameter since WMS1.3.0
-        STRING sVersion = RequestParameter(kpszQueryStringVersion);
+        STRING version = GetRequestVersion();
         // Note: lexical comparison, not numerical one;
-        if(!sVersion.empty() && sVersion >= _("1.3.0"))
+        if(!version.empty() && version >= _("1.3.0"))
         {
             CPSZ pszFormat = RequestParameter(kpszQueryStringInfoFormat);
             if(pszFormat == NULL)
@@ -822,3 +834,18 @@
     m_pLayers = SAFE_ADDREF(pLayerDefs);
 }
 
+// Get WMS request version
+STRING MgOgcWmsServer::GetRequestVersion()
+{
+    CPSZ version = RequestParameter(kpszQueryStringVersion);
+    if(version == NULL)
+    {
+        // In WMS version 1.0.0, the name of this parameter was "WMTVER".
+        // That name is now deprecated, but for backwards compatibility and 
+        // version negotiation a post-1.0.0 server should accept 
+        // either form without issuing a Service Exception.
+        version = RequestParameter(kpszQueryStringVersion);
+    }
+
+    return STRING(version? version : _(""));
+}

Modified: trunk/MgDev/Web/src/HttpHandler/OgcWmsServer.h
===================================================================
--- trunk/MgDev/Web/src/HttpHandler/OgcWmsServer.h	2010-07-28 02:48:32 UTC (rev 5057)
+++ trunk/MgDev/Web/src/HttpHandler/OgcWmsServer.h	2010-07-28 02:50:54 UTC (rev 5058)
@@ -93,6 +93,9 @@
     bool ValidateGetFeatureInfoParameters();
     bool ValidateMapParameters();
     bool ValidateMapParameters(MgStringCollection* queryableLayers);
+    
+    // Hetp method to get WMS request version
+    STRING GetRequestVersion();
 
     CPSZ ServiceExceptionReportElement();
 



More information about the mapguide-commits mailing list