[fusion-commits] r1686 - trunk/layers/MapServer/php

svn_fusion at osgeo.org svn_fusion at osgeo.org
Wed Nov 26 11:50:17 EST 2008


Author: pdeschamps
Date: 2008-11-26 11:50:17 -0500 (Wed, 26 Nov 2008)
New Revision: 1686

Modified:
   trunk/layers/MapServer/php/LoadMap.php
Log:
closes #96


Modified: trunk/layers/MapServer/php/LoadMap.php
===================================================================
--- trunk/layers/MapServer/php/LoadMap.php	2008-11-26 16:10:04 UTC (rev 1685)
+++ trunk/layers/MapServer/php/LoadMap.php	2008-11-26 16:50:17 UTC (rev 1686)
@@ -41,6 +41,8 @@
 /* could potentially make this optional */
 $moveToSession = true;
 
+
+
 /**
    TODO make it possible to specify only a relative path
    in the WebLayout and have this code know where to
@@ -73,9 +75,12 @@
          eg STYLE
              SYMBOL "../etc/markers/target-7.gif" : this is relative to the map file
         */
+
         for ($i=0; $i<$oMap->numlayers; $i++)
         {
-            $oLayer = $oMap->GetLayer($i);
+            $oLayer = &$oMap->GetLayer($i);
+            /* check layername for invalid URI characters and replace */
+            $oLayer->set("name",replaceInvalidLayerName($oLayer->name));
 
             for ($j=0; $j<$oLayer->numclasses; $j++)
             {
@@ -147,6 +152,9 @@
         $layer=$oMap->getLayer($i);
         $layerObj = NULL;
 
+        /* rename layes names with invalid characters */
+        $layer->set("name",replaceInvalidLayerName($layer->name));
+
         $layerObj->metadata = NULL;
         if (isset($_REQUEST['layer_metadata'])) {
             $layerMetadataKeys = explode(',',$_REQUEST['layer_metadata']);
@@ -211,7 +219,7 @@
 
          $selectable = strtolower($layer->getMetaData('selectable'));
          $layerObj->selectable = $selectable == 'true' ? true : false;
-         
+
          $layerObj->visible = ($layer->status == MS_ON || $layer->status == MS_DEFAULT);
          $layerObj->actuallyVisible = true;
 
@@ -336,4 +344,34 @@
       return 1;
 
 }
+
+function replaceInvalidLayerName($szLayerName){
+    /*
+    bug http://trac.osgeo.org/fusion/ticket/96 - Invalid characters in layer name (pdeschamps)
+
+    Fusion requests the map imavge via the Mapserver CGI to toggle the layer visibility.
+    The layer paramerter for the cgi uses spaces as a delimiter for the layer names this creates
+    an issue for the mapserver binary to toggle layers that have these reserved URI characters.
+    also removing characters that could pose potential issues with json.
+    */
+    $aInvalidLayerNameCharacters = array();
+    $aInvalidLayerNameCharacters[0] ="&";
+    $aInvalidLayerNameCharacters[1] =" ";
+    $aInvalidLayerNameCharacters[2] ="#";
+    $aInvalidLayerNameCharacters[3] ="\\";
+    $aInvalidLayerNameCharacters[4] ="=";
+    $aInvalidLayerNameCharacters[5] ="/";
+    $aInvalidLayerNameCharacters[6] ="'";
+
+    $aReplace[0] = "_";
+    $aReplace[1] = "_";
+    $aReplace[2] = "_";
+    $aReplace[3] = "_";
+    $aReplace[4] = "_";
+    $aReplace[5] = "_";
+    $aReplace[6] = "_";
+
+    return str_replace($aInvalidLayerNameCharacters,$aReplace,$szLayerName);
+}
+
 ?>



More information about the fusion-commits mailing list