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

AMP4Email: Set default "amp-allowed-url-macros" and "amp-action-whitelist" #27561

Merged
merged 41 commits into from
Apr 30, 2020

Conversation

caroqliu
Copy link
Contributor

@caroqliu caroqliu commented Apr 3, 2020

This change hardcodes default allowlists for URL replacements and AMP actions for the AMP4Email format and no longer explicitly from the amp-allowed-url-macros and amp-action-whitelist meta tags. This also introduces an allowlist-specific unit tests for AMP actions and affected components, as well as removes the validator tests which asserts the invalidity of the meta tag names.

Fixes #27094

@dreamofabear
Copy link

Re: bundle size, a couple ideas to consider:

  • Remove the code that parses the meta tags. They are invalid AMP intentionally to avoid unsanctioned dependencies. Keep the programmatic API that internal callers rely on (e.g. amp-story for the action whitelist).
  • Delegate storage of the whitelists to each extension.
  • Extract the whitelists into a lazy-loaded binary (actions are not needed immediately on page load, but this may impact time-to-interactive).

@caroqliu
Copy link
Contributor Author

caroqliu commented Apr 6, 2020

@choumx Thanks for the suggestions here--decided to delegate the allowed actions to the extensions. Looks like this resolved the bundle size check.

To clarify on the first option: email is currently the only format for which the meta tags are provided and processed, which is why the change that overrides them should also make them safe to remove. Am I correct in that understanding?

@caroqliu caroqliu requested review from wassgha and krdwan April 6, 2020 21:20
@dreamofabear
Copy link

To clarify on the first option: email is currently the only format for which the meta tags are provided and processed, which is why the change that overrides them should also make them safe to remove. Am I correct in that understanding?

I don't think there's a format-specific restriction on usage of these meta tags. But they're invalid AMP, so they can't be used by publishers and must be injected by viewers. So we know they're safe to remove as long as the relevant viewers are informed -- in this case, those are email providers.

@caroqliu caroqliu requested a review from gmajoulet April 28, 2020 15:15
Copy link
Contributor

@gmajoulet gmajoulet left a comment

Choose a reason for hiding this comment

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

Story usage of the actions whitelist still works 👍

@caroqliu caroqliu removed the request for review from powerivq April 28, 2020 15:49
Copy link
Contributor

@wassgha wassgha left a comment

Choose a reason for hiding this comment

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

Extensions look good to me, you need conduit for owners coverage

@wassgha wassgha requested a review from Gregable April 28, 2020 16:08
@Gregable Gregable removed their request for review April 28, 2020 17:23
*/
addToWhitelist(tagOrTarget, method) {
addToWhitelist(tagOrTarget, methods, opt_forFormat) {
// TODO: When it becomes possible to getFormat(),

Choose a reason for hiding this comment

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

Minor: Can we add a WG for this TODO?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would wg-runtime be appropriate here? 😅

@amp-bundle-size amp-bundle-size bot requested a review from powerivq April 30, 2020 14:55
@caroqliu caroqliu merged commit 3ddd4f4 into ampproject:master Apr 30, 2020
ldoroshe pushed a commit to ldoroshe/amphtml that referenced this pull request May 8, 2020
…list" (ampproject#27561)

* Allow no URL macros for email

* Set default actions allowlist for email

* Update comments for variable-source

* Add missing actions

* Add unit tests

* Check existence of `hasAttribute`

* Delegate allowed actions to components

* Remove queryWhitelist method

* Remove action-white-list meta from tests

* Don't make every component check email format

* Move action allowlist tests to separate file

* Remove unparseable allowlist entries

* Use getActionInvocation helper method

* Add component-based  tests and associated fixes

* Stub maybeAddToEmailWhitelist in test-amp-form

* Remove extra line

* Do not allow duplicate actions

* Remove "amp-allowed-url-macros" meta

* Remove validator cases for meta tags

* Stub hasAttribute in test-url-replacements

* Fix type annotation

* Replace maybeAddToEmailWhitelist with opts

* Annotate void return

* Fixes to unit tests

* Take Arrays of methods, formats, in addToWhitelist

* Replace use of hasOwn

* Add warning for ignored whitelist entries

* Move action unit tests to component unit tests

* Move allowlist unit tests back to test-action.js

* Fix warning args

* Delete test-action-allowlist.js

* Remove unnecessary arg

* Remove validator tests for meta

* Assert valid whitelist entries

* Replace `invoke_` with `execute` in unit tests.

* Stub user().error

* Use sandbox.spy/stub

* Add wg-runtime to TODO comment

* (empty)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AMP4Email: Standardize email meta whitelists
7 participants