From af97f091505f4d792e60ad10c7e7299cb77448a6 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Thu, 2 May 2019 10:22:37 -0400 Subject: [PATCH] Remove "key=value" pasting into raw tag editor key (Reverts: #6211, #5070, #5024) The old code allows users to circumvent the readonly tag protection see https://github.com/openstreetmap/iD/issues/6185#issuecomment-488692351 We'll offer a text-mode instead, with stricter checks on which keys can be modified. --- modules/ui/raw_tag_editor.js | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/modules/ui/raw_tag_editor.js b/modules/ui/raw_tag_editor.js index ee5d97ac2..8fc8daacd 100644 --- a/modules/ui/raw_tag_editor.js +++ b/modules/ui/raw_tag_editor.js @@ -77,7 +77,7 @@ export function uiRawTagEditor(context) { // --------- EXPERIMENT! var options = wrap.selectAll('.raw-tag-options') - .data([0]) + .data([0]); var optionsEnter = options.enter() .append('div') @@ -362,25 +362,7 @@ export function uiRawTagEditor(context) { _pendingChange[kOld] = undefined; } - // if the key looks like "key=value key2=value2", split them up - #5024 - var keys = (kNew.match(/[\w_]+=/g) || []).map(function (key) { return key.slice(0, -1); }); - var vals = keys.length === 0 - ? [] - : kNew - .split(new RegExp(keys.map(function (key) { return key.replace('_', '\\_'); }).join('|'))) - .splice(1) - .map(function (val) { return val.slice(1).trim(); }); - - if (keys.length > 0) { - kNew = keys[0]; - vNew = vals[0]; - - keys.forEach(function (key, i) { - _pendingChange[key] = vals[i]; - }); - } else { - _pendingChange[kNew] = vNew; - } + _pendingChange[kNew] = vNew; d.key = kNew; // update datum to avoid exit/enter on tag update d.value = vNew;