Skip to content

Commit

Permalink
Use non-capturing regex for data to prevent memory exhaustion for lon…
Browse files Browse the repository at this point in the history
…g strings (#4741).
  • Loading branch information
ricmoo committed May 29, 2024
1 parent 8b5dfca commit 5463aa0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src.ts/utils/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function _getBytes(value: BytesLike, name?: string, copy?: boolean): Uint8Array
return value;
}

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

0 comments on commit 5463aa0

Please sign in to comment.