File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -331,6 +331,21 @@ export default class _Blockly {
331
331
332
332
try {
333
333
xml = Blockly . Xml . textToDom ( blockStr ) ;
334
+ const blocklyXml = xml . querySelectorAll ( 'block' ) ;
335
+
336
+ if ( blocklyXml . length <= 0 ) {
337
+ globalObserver . emit ( 'ui.log.warn' , `${ translate ( 'Unrecognized file format' ) } ` ) ;
338
+ return ;
339
+ }
340
+
341
+ blocklyXml . forEach ( block => {
342
+ const blockType = block . attributes . type . nodeValue ;
343
+
344
+ if ( ! Object . keys ( Blockly . Blocks ) . includes ( blockType ) ) {
345
+ globalObserver . emit ( 'ui.log.warn' , `${ translate ( 'Unrecognized file format' ) } ` ) ;
346
+ throw createError ( 'FileLoad' , translate ( 'Unrecognized file format' ) ) ;
347
+ }
348
+ } ) ;
334
349
} catch ( e ) {
335
350
throw createError ( 'FileLoad' , translate ( 'Unrecognized file format' ) ) ;
336
351
}
You can’t perform that action at this time.
0 commit comments