From ced088c4faa626e1bf8cf53ce2ea50b0d9e6af77 Mon Sep 17 00:00:00 2001 From: Will Yang Date: Wed, 3 Jan 2018 14:15:54 +1100 Subject: [PATCH] unescape quotes when necessary to compatible with old filter patterns --- .../aws/package/compile/events/cloudWatchLog/index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/plugins/aws/package/compile/events/cloudWatchLog/index.js b/lib/plugins/aws/package/compile/events/cloudWatchLog/index.js index 304bf19ba..697d9736d 100644 --- a/lib/plugins/aws/package/compile/events/cloudWatchLog/index.js +++ b/lib/plugins/aws/package/compile/events/cloudWatchLog/index.js @@ -78,6 +78,13 @@ class AwsCompileCloudWatchLogEvents { .getLambdaCloudWatchLogPermissionLogicalId(functionName, cloudWatchLogNumberInFunction); + // unescape quotes once when the first quote is detected escaped + const idxFirstSlash = FilterPattern.indexOf('\\'); + const idxFirstQuote = FilterPattern.indexOf('"'); + if (idxFirstSlash >= 0 && idxFirstQuote >= 0 && idxFirstQuote > idxFirstSlash) { + FilterPattern = FilterPattern.replace(/\\("|\\|')/g, (match, g) => g); + } + const cloudWatchLogRuleTemplate = ` { "Type": "AWS::Logs::SubscriptionFilter",