From 4722ee62bd16b68846ecfc19e19e62b5bc769c01 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Wed, 2 Oct 2013 17:36:45 +0200 Subject: [PATCH] escape_id moves into plugin.js --- manifold/static/js/plugin.js | 11 ++++++++++- plugins/googlemap/static/js/googlemap.js | 4 ++-- unfold/static/js/unfold-helper.js | 8 -------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/manifold/static/js/plugin.js b/manifold/static/js/plugin.js index 3745f649..07ba9b71 100644 --- a/manifold/static/js/plugin.js +++ b/manifold/static/js/plugin.js @@ -189,7 +189,7 @@ var Plugin = Class.extend({ id_from_key: function(key_field, value) { - return key_field + manifold.separator + unfold.escape_id(value).replace(/\\/g, ''); + return key_field + manifold.separator + this.escape_id(value).replace(/\\/g, ''); }, // we do not need to carry around all the nonsense about backslashing dots in hrns @@ -205,6 +205,15 @@ var Plugin = Class.extend({ return id_in.replace(/\\\./g,"-").replace(/\\/g,"-").replace(/\./g,"-"); }, + // escape (read: backslashes) some meta-chars in input + escape_id: function(id) { + if( id !== undefined){ + return id.replace( /(:|\.|\[|\])/g, "\\$1" ); + }else{ + return "undefined-id"; + } + }, + id_from_record: function(method, record) { var keys = manifold.metadata.get_key(method); if (!keys) diff --git a/plugins/googlemap/static/js/googlemap.js b/plugins/googlemap/static/js/googlemap.js index 34b2b8de..345a2b92 100644 --- a/plugins/googlemap/static/js/googlemap.js +++ b/plugins/googlemap/static/js/googlemap.js @@ -102,7 +102,7 @@ googlemap_debug_detailed=false; throw "Not implemented"; break; } - return unfold.escape_id(key_value).replace(/\\/g, ''); + return this.escape_id(key_value).replace(/\\/g, ''); }, // return { marker: gmap_marker, ul :