From d68754267e072bf1039772a1a28714cf0a200b04 Mon Sep 17 00:00:00 2001 From: Blast Z Date: Thu, 2 Jul 2020 21:58:30 +0800 Subject: [PATCH] fix(common): escape replaced value Something like this `log('I like %O', { name: '%sugar%' });` will cause output incorrect. --- src/common.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common.js b/src/common.js index da7eada6..0a61203c 100644 --- a/src/common.js +++ b/src/common.js @@ -99,6 +99,7 @@ function setup(env) { if (typeof formatter === 'function') { const val = args[index]; match = formatter.call(self, val); + match = match.replace(/%/g, () => '%%'); // Now we need to remove `args[index]` since it's inlined in the `format` args.splice(index, 1);