Skip to content

Commit

Permalink
✨ [RTC-Config]: add source_url and title to real-time-config global m…
Browse files Browse the repository at this point in the history
…acros allowlist (#38723)

* add source_url and title to real-time-config global macro allowlist

* add back accidently removed regex token

* fix unit test
  • Loading branch information
Zeeshan Rasool authored Jul 23, 2023
1 parent 6a27fa8 commit 810596b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/service/real-time-config/real-time-config-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ export const RTC_ERROR_ENUM = {
};

/** @const {!{[key: string]: boolean}} */
const GLOBAL_MACRO_ALLOWLIST = {CLIENT_ID: true};
const GLOBAL_MACRO_ALLOWLIST = {
CLIENT_ID: true,
TITLE: true,
SOURCE_URL: true,
};

export class RealTimeConfigService {
/**
Expand Down
11 changes: 5 additions & 6 deletions test/unit/test-real-time-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,8 @@ describes.realWin('real-time-config service', {amp: true}, (env) => {
* Both save and retrieve to a cookie named `foo`. They should be isolated and the cookies should not be shared.
* But, for some reason they are. So, for now use a cookie called bar here.
*/
const url = 'https://www.foo.example/?cid=CLIENT_ID(bar)';
const url =
'https://www.foo.example/?title=TITLE&src=SOURCE_URL&cid=CLIENT_ID(bar)';
rtc.rtcConfig_ = {
timeoutMillis: 1000,
};
Expand All @@ -809,11 +810,9 @@ describes.realWin('real-time-config service', {amp: true}, (env) => {
);
await rtc.promiseArray_[0];
expect(fetchJsonStub).to.be.called;
expect(
fetchJsonStub.calledWithMatch(
/https:\/\/www.foo.example\/\?cid=amp-\S+$/
)
).to.be.true;
expect(fetchJsonStub).to.be.calledWithMatch(
/https:\/\/www\.foo\.example\/\?title=[^&]*&src=[^&]*&cid=amp-\S+$/
);
});
});

Expand Down

0 comments on commit 810596b

Please sign in to comment.