@@ -43,8 +43,11 @@ class GraphLoadSave extends GraphUndoRedo {
4343 }
4444 if ( format === 'PNG-EMBEDDED' ) {
4545 const b64Uri = this . cy . png ( { full : true } ) ;
46- const b64Data = b64Uri . split ( ',' ) [ 1 ] ;
47- const buffer = new Uint8Array ( window . atob ( b64Data ) . split ( '' ) . map ( ( c ) => c . charCodeAt ( 0 ) ) ) ;
46+ const binaryString = window . atob ( b64Uri . split ( ',' ) [ 1 ] ) ;
47+ const buffer = new Uint8Array ( binaryString . length ) ;
48+ for ( let i = 0 ; i < binaryString . length ; i += 1 ) {
49+ buffer [ i ] = binaryString . charCodeAt ( i ) ;
50+ }
4851 const chunks = extractChunks ( buffer ) ;
4952 chunks . splice ( - 1 , 0 , textChunk . encode ( 'graphml' , this . getGraphML ( ) ) ) ;
5053 const newBuffer = new Uint8Array ( encodeChunks ( chunks ) ) ;
@@ -54,8 +57,11 @@ class GraphLoadSave extends GraphUndoRedo {
5457 }
5558 if ( format === 'JPG-EMBEDDED' ) {
5659 const b64Uri = this . cy . jpg ( { full : true } ) ;
57- const b64Data = b64Uri . split ( ',' ) [ 1 ] ;
58- const buffer = new Uint8Array ( window . atob ( b64Data ) . split ( '' ) . map ( ( c ) => c . charCodeAt ( 0 ) ) ) ;
60+ const binaryString = window . atob ( b64Uri . split ( ',' ) [ 1 ] ) ;
61+ const buffer = new Uint8Array ( binaryString . length ) ;
62+ for ( let i = 0 ; i < binaryString . length ; i += 1 ) {
63+ buffer [ i ] = binaryString . charCodeAt ( i ) ;
64+ }
5965 const graphMLStr = this . getGraphML ( ) ;
6066 const graphMLBytes = new TextEncoder ( ) . encode ( graphMLStr ) ;
6167
0 commit comments