From a83535db5de3c76bc7e5b9072a1b26ff44851efa Mon Sep 17 00:00:00 2001 From: Casey Occhialini <1508707+littlespex@users.noreply.github.com> Date: Mon, 31 Jan 2022 02:05:55 -0800 Subject: [PATCH] Improve special character escaping in CMCD string values (#3866) --- src/streaming/models/CmcdModel.js | 3 +-- test/unit/streaming.models.CmcdModel.js | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/streaming/models/CmcdModel.js b/src/streaming/models/CmcdModel.js index e03b79984b..3706d59216 100644 --- a/src/streaming/models/CmcdModel.js +++ b/src/streaming/models/CmcdModel.js @@ -512,8 +512,7 @@ function CmcdModel() { let cmcdString = keys.reduce((acc, key, index) => { if (key === 'v' && cmcdData[key] === 1) return acc; // Version key should only be reported if it is != 1 if (typeof cmcdData[key] === 'string' && key !== 'ot' && key !== 'sf' && key !== 'st') { - let string = cmcdData[key].replace(/"/g, '\"'); - acc += `${key}="${string}"`; + acc += `${key}=${JSON.stringify(cmcdData[key])}`; } else { acc += `${key}=${cmcdData[key]}`; } diff --git a/test/unit/streaming.models.CmcdModel.js b/test/unit/streaming.models.CmcdModel.js index 5b15760513..e6a83d87d3 100644 --- a/test/unit/streaming.models.CmcdModel.js +++ b/test/unit/streaming.models.CmcdModel.js @@ -332,7 +332,7 @@ describe('CmcdModel', function () { expect(metrics.sf).to.equal('s'); }); - it('getHeaderParameters() returns CID in metrics if expicitly set', function () { + it('getHeaderParameters() returns CID in metrics if explicitly set', function () { const REQUEST_TYPE = HTTPRequest.MPD_TYPE; const MEDIA_TYPE = 'video'; const CID = 'content_id'; @@ -623,7 +623,7 @@ describe('CmcdModel', function () { expect(metrics.sf).to.equal('s'); }); - it('getQueryParameter() returns CID in metrics if expicitly set', function () { + it('getQueryParameter() returns CID in metrics if explicitly set', function () { const REQUEST_TYPE = HTTPRequest.MPD_TYPE; const MEDIA_TYPE = 'video'; const CID = 'content_id';