From 70a760489e1175b255d527b3d900375463f20076 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Sat, 11 May 2019 11:10:03 +0200 Subject: [PATCH] Fix parsing iframe when text contain two iframes cf #689 --- umap/static/umap/js/umap.core.js | 6 +++--- umap/static/umap/test/Util.js | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/umap/static/umap/js/umap.core.js b/umap/static/umap/js/umap.core.js index c27c2bc6..70edfb8f 100644 --- a/umap/static/umap/js/umap.core.js +++ b/umap/static/umap/js/umap.core.js @@ -81,9 +81,9 @@ L.Util.toHTML = function (r) { r = r.replace(/\[\[([^|]*?)\|(.*?)\]\]/g, '$2'); // iframe - r = r.replace(/{{{(h_t_t_ps?[^ |]*)}}}/g, ''); - r = r.replace(/{{{(h_t_t_ps?[^ |]*)\|(\d*)(px)?}}}/g, ''); - r = r.replace(/{{{(h_t_t_ps?[^ |]*)\|(\d*)(px)?\*(\d*)(px)?}}}/g, ''); + r = r.replace(/{{{(h_t_t_ps?[^ |{]*)}}}/g, ''); + r = r.replace(/{{{(h_t_t_ps?[^ |{]*)\|(\d*)(px)?}}}/g, ''); + r = r.replace(/{{{(h_t_t_ps?[^ |{]*)\|(\d*)(px)?\*(\d*)(px)?}}}/g, ''); // images r = r.replace(/{{([^\]|]*?)}}/g, ''); diff --git a/umap/static/umap/test/Util.js b/umap/static/umap/test/Util.js index ea8d6b2d..b6b96c0b 100644 --- a/umap/static/umap/test/Util.js +++ b/umap/static/umap/test/Util.js @@ -94,6 +94,10 @@ describe('L.Util', function () { assert.equal(L.Util.toHTML('A simple iframe: {{{https://osm.org/?url=https%3A//anotherurl.com}}}'), 'A simple iframe: '); }); + it('should handle iframe with height with px', function () { + assert.equal(L.Util.toHTML('A double iframe: {{{https://osm.org/pouet}}}{{{https://osm.org/boudin}}}'), 'A double iframe: '); + }); + it('http link with http link as parameter as variable', function () { assert.equal(L.Util.toHTML('A phrase with a [[http://iframeurl.com?to=http://another.com]].'), 'A phrase with a http://iframeurl.com?to=http://another.com.'); });