Skip to content

Commit f0dfbe1

Browse files
committed
Support RegExp engines with string length limitations (#4967).
1 parent 855d727 commit f0dfbe1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src.ts/utils/data.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ function _getBytes(value: BytesLike, name?: string, copy?: boolean): Uint8Array
3131
return value;
3232
}
3333

34-
if (typeof(value) === "string" && value.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)) {
34+
if (typeof(value) === "string" && (value.length % 2) === 0 &&
35+
value.match(/^0x[0-9a-f]*$/i)) {
3536
const result = new Uint8Array((value.length - 2) / 2);
3637
let offset = 2;
3738
for (let i = 0; i < result.length; i++) {

0 commit comments

Comments
 (0)