From 6ef84035ca1492ccb608f66994397ecdd2a055f1 Mon Sep 17 00:00:00 2001 From: Neil Fraser Date: Wed, 25 Sep 2019 19:49:08 -0700 Subject: [PATCH] Prevent dataset IDs from being renamed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The JS Compiler would rename ‘id’ and ‘blockId’ to something random. Normally that would be fine, but if it ended up with a ‘$’ in the name, then that becomes an illegal HTML property name and Blockly crashes. A bug that’s been lurking in Blockly for years and randomly surfaced on a recent compile. --- core/block_svg.js | 2 +- core/bubble.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/block_svg.js b/core/block_svg.js index e9b709356..4b697eee3 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -115,7 +115,7 @@ Blockly.BlockSvg = function(workspace, prototypeName, opt_id) { // Expose this block's ID on its top-level SVG group. if (this.svgGroup_.dataset) { - this.svgGroup_.dataset.id = this.id; + this.svgGroup_.dataset['id'] = this.id; } /** diff --git a/core/bubble.js b/core/bubble.js index 66163f7dd..3785cb176 100644 --- a/core/bubble.js +++ b/core/bubble.js @@ -288,7 +288,7 @@ Blockly.Bubble.prototype.getSvgRoot = function() { */ Blockly.Bubble.prototype.setSvgId = function(id) { if (this.bubbleGroup_.dataset) { - this.bubbleGroup_.dataset.blockId = id; + this.bubbleGroup_.dataset['blockId'] = id; } };