Skip to content

Commit c2af9b7

Browse files
fix(publish-flat): Regular expression injection (#1081)
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 61061a9 commit c2af9b7

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

packages/publish-flat/src/PublishFlat.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ export class PublishFlat {
4747

4848
this.packageDir = path.resolve(this.options.packageDir);
4949
this.dirToFlatten = this.cleanDirName(this.options.dirToFlatten);
50-
this.dirToFlattenRegex = new RegExp(`${this.dirToFlatten}[\\/]`);
50+
const escapedDirToFlatten = this.dirToFlatten.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
51+
this.dirToFlattenRegex = new RegExp(`${escapedDirToFlatten}[\\/]`);
5152
}
5253

5354
async build(): Promise<string | void> {

0 commit comments

Comments
 (0)