From 9b9c2d6a7670a81d8e3df4513e7ceaa8d5652618 Mon Sep 17 00:00:00 2001 From: Carlos Serrano Date: Mon, 28 Jan 2019 09:16:13 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9C=20fix=20nested=20cdata=20in?= =?UTF-8?q?=20AdParameters?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fixtures/vast-vpaid-inline.xml | 2 +- src/adUnit/helpers/vpaid/__tests__/initAd.spec.js | 2 +- src/vastSelectors/__tests__/index.spec.js | 2 +- src/vastSelectors/index.js | 7 +++++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/fixtures/vast-vpaid-inline.xml b/fixtures/vast-vpaid-inline.xml index a71e19ad..19b44dfd 100644 --- a/fixtures/vast-vpaid-inline.xml +++ b/fixtures/vast-vpaid-inline.xml @@ -49,7 +49,7 @@ https://test.example.com/html5.js https://test.example.com/flash.swf - + ]]> https://test.example.com/icon/staticResource diff --git a/src/adUnit/helpers/vpaid/__tests__/initAd.spec.js b/src/adUnit/helpers/vpaid/__tests__/initAd.spec.js index e1d89e32..56f6a38f 100644 --- a/src/adUnit/helpers/vpaid/__tests__/initAd.spec.js +++ b/src/adUnit/helpers/vpaid/__tests__/initAd.spec.js @@ -39,7 +39,7 @@ describe('initAd', () => { 'thumbnail', -1, { - AdParameters: 'AD_PARAMETERS_DATA', + AdParameters: 'AD_PARAMETERS_DATA ', xmlEncoded: false }, { diff --git a/src/vastSelectors/__tests__/index.spec.js b/src/vastSelectors/__tests__/index.spec.js index a4ee7f5a..c9e55846 100644 --- a/src/vastSelectors/__tests__/index.spec.js +++ b/src/vastSelectors/__tests__/index.spec.js @@ -595,7 +595,7 @@ test('getCreativeData must return the adParameters', () => { }); expect(getCreativeData(vastVpaidInlineXML)).toEqual({ - AdParameters: 'AD_PARAMETERS_DATA', + AdParameters: 'AD_PARAMETERS_DATA ', xmlEncoded: false }); }); diff --git a/src/vastSelectors/index.js b/src/vastSelectors/index.js index ebfc2a8e..f99548d5 100644 --- a/src/vastSelectors/index.js +++ b/src/vastSelectors/index.js @@ -501,8 +501,11 @@ const getAdParametersContent = (xml) => { const paramsRegex = /([\s\S]*)<\/AdParameters>/gm; const result = paramsRegex.exec(xml); - return result && result[1].replace('', '') + return result && result[1].replace(/[\n\s]*[\n\s]*$/, '') + + // unescape nested CDATA + .replace(/\]\]\]\]>/, ']]>') .trim(); };