You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/js/protocols/CapacitorSocket.js
+14-11Lines changed: 14 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -5,16 +5,14 @@ function base64ToUint8Array(b64) {
5
5
constlen=binary.length;
6
6
constbytes=newUint8Array(len);
7
7
for(leti=0;i<len;i++){
8
-
bytes[i]=binary.codePointAt(i);// was using charCodeAt
8
+
// The atob() function returns a binary string where each character represents a single byte (0–255).
9
+
// codePointAt() is designed for Unicode code points and can return values greater than 255, which will overflow Uint8Array slots and corrupt received data.
10
+
// Use charCodeAt(i) to safely extract byte values.
11
+
bytes[i]=binary.charCodeAt(i);
9
12
}
10
13
returnbytes;
11
14
}
12
15
13
-
asyncfunctionblob2uint(blob){
14
-
constbuffer=awaitnewResponse(blob).arrayBuffer();
15
-
returnnewUint8Array(buffer);
16
-
}
17
-
18
16
classCapacitorSocketextendsEventTarget{
19
17
constructor(){
20
18
super();
@@ -37,12 +35,14 @@ class CapacitorSocket extends EventTarget {
0 commit comments