diff --git a/lib/carto/tree/filterset.js b/lib/carto/tree/filterset.js index 882cf7d..7e2b82e 100644 --- a/lib/carto/tree/filterset.js +++ b/lib/carto/tree/filterset.js @@ -92,7 +92,7 @@ tree.Filterset.prototype.toJS = function(env) { val = filter._val.toString(true); } var attrs = "data"; - return attrs + "." + filter.key.value + " " + op + " " + (val.is === 'string' ? "'"+ val +"'" : val); + return attrs + "." + filter.key.value + " " + op + " " + (val.is === 'string' ? "'" + val.toString().replace(/'/g, "\\'") + "'" : val); }).join(' && '); }; diff --git a/test/rendering_js.test.js b/test/rendering_js.test.js index b7fa962..e4be6ac 100644 --- a/test/rendering_js.test.js +++ b/test/rendering_js.test.js @@ -129,7 +129,14 @@ describe('RenderingJS', function() { shader = (new carto.RendererJS({ debug: true })).render(style); layer0 = shader.getLayers()[0]; assert(layer0.isVariable()); + }); + it("should parse styles with string", function() { + var style = '#test { [column = "test\'ing"] { marker-width: 10; } }'; + var shader = (new carto.RendererJS({ debug: true })).render(style); + var layer = shader.getLayers()[0]; + var props = layer.getStyle({column: 'test\'ing'}, { 'zoom': 0, 'frame-offset': 10 }); + assert(props['marker-width'] === 10); }); });