From d3d551e45f877ea89182a4c6891e7eabaceed38c Mon Sep 17 00:00:00 2001 From: dbauszus-glx Date: Thu, 2 Nov 2023 20:03:11 +0000 Subject: [PATCH] prevent regex backtracking --- mod/provider/cloudfront.js | 2 +- mod/provider/file.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mod/provider/cloudfront.js b/mod/provider/cloudfront.js index bc45241d5..17a9e34c0 100644 --- a/mod/provider/cloudfront.js +++ b/mod/provider/cloudfront.js @@ -11,7 +11,7 @@ module.exports = async ref => { try { // Subtitutes {*} with process.env.SRC_* key values. - const url = (ref.params?.url || ref).replace(/[{](.*?)[}]/g, + const url = (ref.params?.url || ref).replace(/{(?!{)(.*?)}/g, matched => process.env[`SRC_${matched.replace(/(^{)|(}$)/g, '')}`]) const date = new Date(Date.now()) diff --git a/mod/provider/file.js b/mod/provider/file.js index 424f6c0c6..7e9794935 100644 --- a/mod/provider/file.js +++ b/mod/provider/file.js @@ -6,7 +6,7 @@ module.exports = async ref => { try { // Subtitutes {*} with process.env.SRC_* key values. - const path = (ref.params?.url || ref).replace(/[{](.*?)[}]/g, + const path = (ref.params?.url || ref).replace(/{(?!{)(.*?)}/g, matched => process.env[`SRC_${matched.replace(/(^{)|(}$)/g, '')}`]) const file = readFileSync(join(__dirname, `../../${path}`))