Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delete pubcommon test cookie for domainOverride after writing it in all cases #5943

Merged
merged 3 commits into from
Nov 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/lunamediahbBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const spec = {
schain: bid.schain || {},
};
const mediaType = bid.mediaTypes

if (mediaType && mediaType[BANNER] && mediaType[BANNER].sizes) {
placement.sizes = mediaType[BANNER].sizes;
placement.traffic = BANNER;
Expand Down
15 changes: 8 additions & 7 deletions modules/pubCommonIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function storeData(config, value) {

if (config.storage.type === COOKIE) {
if (storage.cookiesAreEnabled()) {
storage.setCookie(key, value, expiresStr, 'LAX', COOKIE_DOMAIN);
storage.setCookie(key, value, expiresStr, 'LAX', pubCommonIdSubmodule.domainOverride());
}
} else if (config.storage.type === LOCAL_STORAGE) {
if (storage.hasLocalStorage()) {
Expand Down Expand Up @@ -282,16 +282,19 @@ export const pubCommonIdSubmodule = {
domainOverride: function () {
const domainElements = document.domain.split('.');
const cookieName = `_gd${Date.now()}`;
for (let i = 0, topDomain; i < domainElements.length; i++) {
for (let i = 0, topDomain, testCookie; i < domainElements.length; i++) {
const nextDomain = domainElements.slice(i).join('.');

// write test cookie
storage.setCookie(cookieName, '1', undefined, undefined, nextDomain);

// read test cookie to verify domain was valid
if (storage.getCookie(cookieName) === '1') {
// delete test cookie
storage.setCookie(cookieName, '', 'Thu, 01 Jan 1970 00:00:01 GMT', undefined, nextDomain);
testCookie = storage.getCookie(cookieName);

// delete test cookie
storage.setCookie(cookieName, '', 'Thu, 01 Jan 1970 00:00:01 GMT', undefined, nextDomain);

if (testCookie === '1') {
// cookie was written successfully using test domain so the topDomain is updated
topDomain = nextDomain;
} else {
Expand All @@ -302,6 +305,4 @@ export const pubCommonIdSubmodule = {
}
};

const COOKIE_DOMAIN = pubCommonIdSubmodule.domainOverride();

submodule('userId', pubCommonIdSubmodule);