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

Don't use Fast Fetch with AdSense or DoubleClick on non-Google AMP caches #10872

Merged
merged 3 commits into from Aug 10, 2017
Merged

Don't use Fast Fetch with AdSense or DoubleClick on non-Google AMP caches #10872

merged 3 commits into from Aug 10, 2017

Conversation

taymonbeal
Copy link
Member

Fixes #10871.

mockWin.location = parseUrl(
'https://amp.cloudflare.com/some/path/to/content.html');
sandbox.stub(
urls, 'cdnProxyRegex',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this works in practice but shouldn't be done as modules are not really objects and can't be stubbed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

urls isn't a module, it's just an object.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah i stand corrected

return supportsNativeCrypto &&
(isProxyOrigin(win.location) || getMode(win).localDev ||
(googleCdnProxyRegex.test(win.location.origin) || getMode(win).localDev ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not seeing how this is functionally different from what isProxyOrigin does, i.e., it's basically
return urls.cdnProxyRegex.test(url.origin); where urls.cdnProxyRegex is the same as what you've added above (unless overridden).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Unless overridden" is exactly the scenario where the problem manifests. urls.cdnProxyRegex can be overridden in AMP_CONFIG, and Cloudflare does so.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, OK.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To see for yourself, search for the following string in https://amp.cloudflare.com/v0.js: "cdnProxyRegex":/^https:\/\/([a-zA-Z0-9_-]+\.)?amp\.cloudflare\.com/,

Copy link
Contributor

@jonkeller jonkeller Aug 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this will match https://cdn.ampproject.org.badguys.com/etc - I suggest adding a trailing slash to googleCdnProxyRegex.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. We can't add a trailing slash though, that won't match an origin; we need a trailing $. Also, that regex was copy-pasted from isProxyOrigin so other code has the same bug.

@erwinmombay erwinmombay merged commit 49d564f into ampproject:master Aug 10, 2017
erwinmombay pushed a commit that referenced this pull request Aug 10, 2017
…ches (#10872)

* Don't use Fast Fetch with AdSense or DoubleClick on non-Google AMP caches

* Fix forbidden dependency and add test

* Fix googleCdnProxyRegex
erwinmombay pushed a commit that referenced this pull request Aug 10, 2017
…ches (#10872)

* Don't use Fast Fetch with AdSense or DoubleClick on non-Google AMP caches

* Fix forbidden dependency and add test

* Fix googleCdnProxyRegex
@taymonbeal taymonbeal deleted the google-ads-google-only branch August 11, 2017 17:19
@aghassemi
Copy link
Contributor

@erwinmombay @lannka Was this also patched into Canary (1502234866079)?

aghassemi pushed a commit that referenced this pull request Aug 15, 2017
…ches (#10872)

* Don't use Fast Fetch with AdSense or DoubleClick on non-Google AMP caches

* Fix forbidden dependency and add test

* Fix googleCdnProxyRegex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants