mapbox / carto

fast CSS-like map stylesheets
https://cartocss.readthedocs.io/
Apache License 2.0
653 stars 129 forks source link

Layer names aren't escaped correctly in XML output #273

Closed rcoup closed 7 years ago

rcoup commented 11 years ago

Hi there,

despite the best efforts of #263 / #265, layer names still aren't escaped in the XML output.

foo.mml

{
  "description": "",
  "format": "png",
  "minzoom": 0,
  "maxzoom": 20,
  "name": "",
  "interactivity": false,
  "Layer": [
    {
      "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over",
      "srs-name": "900913",
      "Datasource": {
        "inline": "id,wkt\n1,\"MULTIPOLYGON(((19435453 -4418305,19438622 -4418305,19438622 -4413138,19438789 -4412930,19442125 -4412930,19442292 -4413138,19442292 -4418305,19451967 -4418305,19451967 -4413138,19452134 -4412930,19458806 -4412930,19458973 -4413138,19458973 -4423683,19461975 -4423683,19461975 -4418514,19462142 -4418305,19468814 -4418305,19468981 -4418514,19468981 -4429064,19472150 -4429064,19472317 -4429273,19472317 -4439834,19475487 -4439834,19475653 -4440043,19475653 -4445223,19482159 -4445223,19482326 -4445432,19482326 -4450824,19482159 -4451033,19475653 -4451033,19475653 -4456219,19475487 -4456428,19472150 -4456428,19471984 -4456219,19471984 -4445641,19468981 -4445641,19468981 -4450824,19468814 -4451033,19462142 -4451033,19461975 -4450824,19461975 -4445641,19448797 -4445641,19448631 -4445432,19448631 -4429482,19435453 -4429482,19435453 -4418305)),((19465478 -4472629,19465311 -4472420,19465311 -4461616,19465478 -4461407,19475487 -4461407,19475653 -4461616,19475653 -4467017,19475487 -4467226,19472317 -4467226,19472317 -4472210,19478823 -4472210,19478990 -4472420,19478990 -4477825,19471984 -4477825,19471984 -4472629,19465478 -4472629)),((19512184 -4349049,19512017 -4348842,19512017 -4343501,19512184 -4343294,19515520 -4343294,19515687 -4343501,19515687 -4348842,19515520 -4349049,19512184 -4349049)),((19512184 -4333034,19512017 -4332827,19512017 -4316837,19512184 -4316631,19515353 -4316631,19515353 -4306190,19529032 -4306190,19529032 -4311306,19532201 -4311306,19532368 -4311512,19532368 -4321958,19538873 -4321958,19539040 -4322165,19539040 -4327495,19538873 -4327701,19535704 -4327701,19535704 -4332621,19538873 -4332621,19539040 -4332827,19539040 -4337956,19542209 -4337956,19542209 -4349049,19528865 -4349049,19528698 -4348842,19528698 -4343708,19525529 -4343708,19525362 -4343501,19525362 -4338370,19518856 -4338370,19518690 -4338163,19518690 -4333034,19512184 -4333034)))\"\n",
        "type": "csv"
      },
      "extent": [
        174.85986681380007,
        -37.277269415999911,
        175.01270893820003,
        -36.811966958049908
      ],
      "geometry": "polygon",
      "name": "Area of Deprivation Index 2006 (Indices 9 & 10)",
      "id": "x585area",
      "advanced": {},
      "class": "layer-585-area"
    }
  ],
  "scale": 1,
  "center": [
    175.07114857400006,
    -36.658864074999912,
    9
  ],
  "metatile": 2,
  "bounds": [
    -180,
    -85.051128779806589,
    180,
    85.051128779806589
  ],
  "Stylesheet": [
    {
      "data": ".layer-585-area {\nline-color: #f00;\nline-width: 1.0;\npolygon-opacity: 0.5;\npolygon-fill: #f00;\n}\n",
      "id": "style.mss"
    }
  ],
  "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over"
}

becomes

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Map[]>
<Map srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over" maximum-extent="-20037508.34,-20037508.34,20037508.34,20037508.34">

<Parameters>
  <Parameter name="format">png</Parameter>
  <Parameter name="minzoom">0</Parameter>
  <Parameter name="maxzoom">20</Parameter>
  <Parameter name="center">175.07114857400006,-36.65886407499991,9</Parameter>
  <Parameter name="bounds">-180,-85.05112877980659,180,85.05112877980659</Parameter>
</Parameters>

<Style name="Area of Deprivation Index 2006 (Indices 9 & 10)" filter-mode="first">
  <Rule>
    <LineSymbolizer stroke="#ff0000" stroke-width="1" />
    <PolygonSymbolizer fill-opacity="0.5" fill="#ff0000" />
  </Rule>
</Style>
<Layer name="Area of Deprivation Index 2006 (Indices 9 & 10)"
  srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over">
    <StyleName>Area of Deprivation Index 2006 (Indices 9 & 10)</StyleName>
    <Datasource>
       <Parameter name="inline"><![CDATA[id,wkt
1,"MULTIPOLYGON(((19435453 -4418305,19438622 -4418305,19438622 -4413138,19438789 -4412930,19442125 -4412930,19442292 -4413138,19442292 -4418305,19451967 -4418305,19451967 -4413138,19452134 -4412930,19458806 -4412930,19458973 -4413138,19458973 -4423683,19461975 -4423683,19461975 -4418514,19462142 -4418305,19468814 -4418305,19468981 -4418514,19468981 -4429064,19472150 -4429064,19472317 -4429273,19472317 -4439834,19475487 -4439834,19475653 -4440043,19475653 -4445223,19482159 -4445223,19482326 -4445432,19482326 -4450824,19482159 -4451033,19475653 -4451033,19475653 -4456219,19475487 -4456428,19472150 -4456428,19471984 -4456219,19471984 -4445641,19468981 -4445641,19468981 -4450824,19468814 -4451033,19462142 -4451033,19461975 -4450824,19461975 -4445641,19448797 -4445641,19448631 -4445432,19448631 -4429482,19435453 -4429482,19435453 -4418305)),((19465478 -4472629,19465311 -4472420,19465311 -4461616,19465478 -4461407,19475487 -4461407,19475653 -4461616,19475653 -4467017,19475487 -4467226,19472317 -4467226,19472317 -4472210,19478823 -4472210,19478990 -4472420,19478990 -4477825,19471984 -4477825,19471984 -4472629,19465478 -4472629)),((19512184 -4349049,19512017 -4348842,19512017 -4343501,19512184 -4343294,19515520 -4343294,19515687 -4343501,19515687 -4348842,19515520 -4349049,19512184 -4349049)),((19512184 -4333034,19512017 -4332827,19512017 -4316837,19512184 -4316631,19515353 -4316631,19515353 -4306190,19529032 -4306190,19529032 -4311306,19532201 -4311306,19532368 -4311512,19532368 -4321958,19538873 -4321958,19539040 -4322165,19539040 -4327495,19538873 -4327701,19535704 -4327701,19535704 -4332621,19538873 -4332621,19539040 -4332827,19539040 -4337956,19542209 -4337956,19542209 -4349049,19528865 -4349049,19528698 -4348842,19528698 -4343708,19525529 -4343708,19525362 -4343501,19525362 -4338370,19518856 -4338370,19518690 -4338163,19518690 -4333034,19512184 -4333034)))"
]]></Parameter>
       <Parameter name="type"><![CDATA[csv]]></Parameter>
    </Datasource>
  </Layer>

</Map>

Note the <Layer> and <Style> elements which should look like "Area of Deprivation Index 2006 (Indices 9 &amp; 10)" not ... (Indices 9 & 10)"

(coughs yeah, I know that's not what Layer/style names are for, but I've fixed that bug in my code)

springmeyer commented 11 years ago

Since TileMill sanitizes layer/style names we've not run into the need to wrap them in CDATA or escape them manually. But if you need this then I'd review a pull request with tests alongside it.

springmeyer commented 11 years ago

@rcoup - got a pull request fixing this around?

springmeyer commented 11 years ago

bump @rcoup

rcoup commented 11 years ago

Sorry! Yeah I think I have a patch somewhere, will try and look it out today.

On Thu, Sep 12, 2013 at 3:21 PM, Dane Springmeyer notifications@github.comwrote:

bump @rcoup https://github.com/rcoup

— Reply to this email directly or view it on GitHubhttps://github.com/mapbox/carto/issues/273#issuecomment-24292757 .

springmeyer commented 11 years ago

see also #303

strk commented 10 years ago

@rcoup any news ?

springmeyer commented 10 years ago

bump @rcoup.