Skip to content
This repository was archived by the owner on Jan 27, 2026. It is now read-only.

Defend against empty variable names#156

Merged
joshlory merged 3 commits intomasterfrom
defend-against-empty-var-names
Nov 15, 2018
Merged

Defend against empty variable names#156
joshlory merged 3 commits intomasterfrom
defend-against-empty-var-names

Conversation

@joshlory
Copy link
Contributor

With guidance from @Bjvanminnen, alternate fix for PR code-dot-org/code-dot-org#26085.

@Bjvanminnen
Copy link
Contributor

With this change here https://github.com/code-dot-org/blockly/blob/master/core/ui/fields/field_variable.js#L156 we will still call setText even if newVar is an empty string. I'm not sure what the implications of that are (it might be fine), but is probably worth checking.

Copy link
Contributor

@Bjvanminnen Bjvanminnen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Having this check in renameVariable makes sense to me. Thanks for picking this up!

assertEquals("Cannot rename var to empty", 'z', Blockly.Variables.allVariables()[0]);

goog.dom.removeNode(container);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yay tests!

@joshlory
Copy link
Contributor Author

Ah good catch, fixing the setText issue on line 156.

@joshlory joshlory merged commit 32c478d into master Nov 15, 2018
@joshlory joshlory deleted the defend-against-empty-var-names branch November 15, 2018 20:30
islemaster added a commit to code-dot-org/code-dot-org that referenced this pull request Nov 16, 2018
Picks up code-dot-org/blockly#157 which is essential for this change, as well as code-dot-org/blockly#156 which we wanted to ship anyway, and code-dot-org/blockly#152 from a contributor.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants