Add $ back into the ID soup. Issue #251.

This commit is contained in:
Neil Fraser
2016-10-06 18:52:25 -07:00
parent 157441f4b1
commit 415c6ed65e
4 changed files with 11 additions and 7 deletions

View File

@@ -187,8 +187,9 @@ Blockly.Generator.prototype.blockToCode = function(block) {
'Expecting string from statement block "%s".', block.type);
return [this.scrub_(block, code[0]), code[1]];
} else if (goog.isString(code)) {
var id = block.id.replace(/\$/g, '$$$$'); // Issue 251.
if (this.STATEMENT_PREFIX) {
code = this.STATEMENT_PREFIX.replace(/%1/g, '\'' + block.id + '\'') +
code = this.STATEMENT_PREFIX.replace(/%1/g, '\'' + id + '\'') +
code;
}
return this.scrub_(block, code);
@@ -297,6 +298,7 @@ Blockly.Generator.prototype.statementToCode = function(block, name) {
* @return {string} Loop contents, with infinite loop trap added.
*/
Blockly.Generator.prototype.addLoopTrap = function(branch, id) {
id = id.replace(/\$/g, '$$$$'); // Issue 251.
if (this.INFINITE_LOOP_TRAP) {
branch = this.INFINITE_LOOP_TRAP.replace(/%1/g, '\'' + id + '\'') + branch;
}

View File

@@ -543,12 +543,13 @@ Blockly.genUid = function() {
};
/**
* Legal characters for the unique ID.
* Should be all on a US keyboard. No XML special characters or control codes.
* Removed $ due to issue 251.
* Legal characters for the unique ID. Should be all on a US keyboard.
* No characters that conflict with XML or JSON. Requests to remove additional
* 'problematic' characters from this soup will be denied. That's your failure
* to properly escape in your own environment. Issues #251, #625, #682.
* @private
*/
Blockly.genUid.soup_ = '!#%()*+,-./:;=?@[]^_`{|}~' +
Blockly.genUid.soup_ = '!#$%()*+,-./:;=?@[]^_`{|}~' +
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
/**

View File

@@ -1305,7 +1305,8 @@ Blockly.WorkspaceSvg.prototype.updateGridPattern_ = function() {
* .flyoutWidth: Width of the flyout if it is always open. Otherwise zero.
* .flyoutHeight: Height of flyout if it is always open. Otherwise zero.
* .toolboxPosition: Top, bottom, left or right.
* @return {Object} Contains size and position metrics of a top level workspace.
* @return {!Object} Contains size and position metrics of a top level
* workspace.
* @private
* @this Blockly.WorkspaceSvg
*/

View File

@@ -111,7 +111,7 @@ Blockly.Blocks['unittest_adjustindex'] = {
"output": "Number",
"colour": 65,
"tooltip": "Adjusts the value based on whether generated code is using " +
"zero or one based indexing"
"zero or one based indexing."
});
}
};