From d41f2e22abe73a11e71e10aaa25710da6f36928b Mon Sep 17 00:00:00 2001 From: Sidhartha Chatterjee Date: Thu, 11 Mar 2021 15:27:35 +0530 Subject: [PATCH] fix(gatsby-plugin-netlify): Add an allow list for redirect options (#30155) (cherry picked from commit 962c4a1d3d8a5c952ec88957bdc20352bbeb151c) --- .../src/create-redirects.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/gatsby-plugin-netlify/src/create-redirects.js b/packages/gatsby-plugin-netlify/src/create-redirects.js index 76a2a67c0d14f..b42fc98c90239 100644 --- a/packages/gatsby-plugin-netlify/src/create-redirects.js +++ b/packages/gatsby-plugin-netlify/src/create-redirects.js @@ -12,8 +12,18 @@ export default async function writeRedirectsFile( const FILE_PATH = publicFolder(`_redirects`) - // Map redirect data to the format Netlify expects // https://www.netlify.com/docs/redirects/ + const NETLIFY_REDIRECT_KEYWORDS_ALLOWLIST = [ + `query`, + `conditions`, + `headers`, + `signed`, + `edge_handler`, + `Language`, + `Country`, + ] + + // Map redirect data to the format Netlify expects redirects = redirects.map(redirect => { const { fromPath, @@ -43,7 +53,9 @@ export default async function writeRedirectsFile( `Values should not contain spaces.` ) } else { - pieces.push(`${key}=${value}`) + if (NETLIFY_REDIRECT_KEYWORDS_ALLOWLIST.includes(key)) { + pieces.push(`${key}=${value}`) + } } }