Skip to content

Commit 0274b67

Browse files
authored
Defend against missing options on cookie init (#193)
1 parent 901b9a5 commit 0274b67

File tree

8 files changed

+99
-64
lines changed

8 files changed

+99
-64
lines changed

Sources/ContentScopeScripts/dist/contentScope.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3769,15 +3769,20 @@
37693769
}
37703770

37713771
function init$d (args) {
3772-
args.cookie.debug = args.debug;
3773-
cookiePolicy = args.cookie;
3774-
3775-
const featureName = 'cookie';
3776-
cookiePolicy.shouldBlockTrackerCookie = getFeatureSettingEnabled(featureName, args, 'trackerCookie');
3777-
cookiePolicy.shouldBlockNonTrackerCookie = getFeatureSettingEnabled(featureName, args, 'nonTrackerCookie');
3778-
const policy = getFeatureSetting(featureName, args, 'firstPartyCookiePolicy');
3779-
if (policy) {
3780-
cookiePolicy.policy = policy;
3772+
if (args.cookie) {
3773+
cookiePolicy = args.cookie;
3774+
args.cookie.debug = args.debug;
3775+
3776+
const featureName = 'cookie';
3777+
cookiePolicy.shouldBlockTrackerCookie = getFeatureSettingEnabled(featureName, args, 'trackerCookie');
3778+
cookiePolicy.shouldBlockNonTrackerCookie = getFeatureSettingEnabled(featureName, args, 'nonTrackerCookie');
3779+
const policy = getFeatureSetting(featureName, args, 'firstPartyCookiePolicy');
3780+
if (policy) {
3781+
cookiePolicy.policy = policy;
3782+
}
3783+
} else {
3784+
// no cookie information - disable protections
3785+
cookiePolicy.shouldBlock = false;
37813786
}
37823787

37833788
loadedPolicyResolve();

build/android/contentScope.js

Lines changed: 14 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/chrome-mv3/inject.js

Lines changed: 14 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/chrome/inject.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/firefox/inject.js

Lines changed: 14 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/integration/contentScope.js

Lines changed: 14 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/windows/contentScope.js

Lines changed: 14 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/features/cookie.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,20 @@ export function load (args) {
168168
}
169169

170170
export function init (args) {
171-
args.cookie.debug = args.debug
172-
cookiePolicy = args.cookie
173-
174-
const featureName = 'cookie'
175-
cookiePolicy.shouldBlockTrackerCookie = getFeatureSettingEnabled(featureName, args, 'trackerCookie')
176-
cookiePolicy.shouldBlockNonTrackerCookie = getFeatureSettingEnabled(featureName, args, 'nonTrackerCookie')
177-
const policy = getFeatureSetting(featureName, args, 'firstPartyCookiePolicy')
178-
if (policy) {
179-
cookiePolicy.policy = policy
171+
if (args.cookie) {
172+
cookiePolicy = args.cookie
173+
args.cookie.debug = args.debug
174+
175+
const featureName = 'cookie'
176+
cookiePolicy.shouldBlockTrackerCookie = getFeatureSettingEnabled(featureName, args, 'trackerCookie')
177+
cookiePolicy.shouldBlockNonTrackerCookie = getFeatureSettingEnabled(featureName, args, 'nonTrackerCookie')
178+
const policy = getFeatureSetting(featureName, args, 'firstPartyCookiePolicy')
179+
if (policy) {
180+
cookiePolicy.policy = policy
181+
}
182+
} else {
183+
// no cookie information - disable protections
184+
cookiePolicy.shouldBlock = false
180185
}
181186

182187
loadedPolicyResolve()

0 commit comments

Comments
 (0)