Skip to content

Commit 05b9930

Browse files
rachel-fenichelpicklesrus
authored andcommitted
Don't allow illegal connections to procedure prototype blocks (#1751)
1 parent 149dd3f commit 05b9930

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

core/connection.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,15 @@ Blockly.Connection.prototype.canConnectWithReason_ = function(target) {
312312
return Blockly.Connection.REASON_CHECKS_FAILED;
313313
} else if (blockA.isShadow() && !blockB.isShadow()) {
314314
return Blockly.Connection.REASON_SHADOW_PARENT;
315-
} else if (blockA.type == Blockly.PROCEDURES_DEFINITION_BLOCK_TYPE &&
316-
blockB.type != 'procedures_prototype' &&
317-
superiorConn == blockA.getInput('custom_block').connection ) {
315+
} else if ((blockA.type == Blockly.PROCEDURES_DEFINITION_BLOCK_TYPE &&
316+
blockB.type != Blockly.PROCEDURES_PROTOTYPE_BLOCK_TYPE &&
317+
superiorConn == blockA.getInput('custom_block').connection) ||
318+
(blockB.type == Blockly.PROCEDURES_PROTOTYPE_BLOCK_TYPE &&
319+
blockA.type != Blockly.PROCEDURES_DEFINITION_BLOCK_TYPE)) {
318320
// Hack to fix #1127: Fail attempts to connect to the custom_block input
319321
// on a defnoreturn block, unless the connecting block is a specific type.
322+
// And hack to fix #1534: Fail attempts to connect anything but a
323+
// defnoreturn block to a prototype block.
320324
return Blockly.Connection.REASON_CUSTOM_PROCEDURE;
321325
}
322326
return Blockly.Connection.CAN_CONNECT;

tests/custom_procedure_playground.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,15 @@
133133
</value>
134134
</block>
135135
</category>
136+
<category name="Statements">
137+
<block type="control_forever"></block>
138+
<block type="sound_stopallsounds"></block>
139+
<block type="control_start_as_clone"></block>
140+
<block type="control_stop">
141+
<mutation hasnext="false"></mutation>
142+
<field name="STOP_OPTION">all</field>
143+
</block>
144+
</category>
136145
</xml>
137146

138147
<script>

0 commit comments

Comments
 (0)