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

🐛Fix data-amp-replace comparison logic #19069

Merged
merged 3 commits into from Oct 31, 2018
Merged

🐛Fix data-amp-replace comparison logic #19069

merged 3 commits into from Oct 31, 2018

Conversation

calebcordry
Copy link
Member

Fixes #19061

The new expander had inadvertently introduced a new API that UrlReplacements.collectUnwhitelistedVarsSync_ had become dependent on. When the API was changed back in #18554 it broke the intended functionality of this method.

This removes the arguments collected by the collectVars object before comparing them to the given data-amp-replace options.

@calebcordry
Copy link
Member Author

Working on writing test now, but wanted to get input on the fix. Looks like this test might have caught it but was skipped :(

it.skip('should collect unwhitelisted vars', () => {

const varNames = Object.keys(vars);
const varNames = Object.keys(vars)
// Strip arguments from collect_vars to match whitelist api.
.map(key => key.substring(0, key.indexOf('(')));

Choose a reason for hiding this comment

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

Seems a bit hacky?

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree. A larger refactor is needed to be less so. Wasn't sure if we should patch and clean up after.

Copy link
Contributor

Choose a reason for hiding this comment

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

indeed. is it possible to have spaces before (?

chatted offline, a better fix would redefine this collectUnwhitelistedVarsSync method, and move whitelist logic to the caller.

I'm fine with a quick fix like this to patch prod.

Copy link
Member Author

Choose a reason for hiding this comment

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

Should not be possible to have spaces before arguments.

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought we allow /path/CLIENT_ID (xxx) ? or did it get normalized somewhere down the path?

Copy link
Member Author

Choose a reason for hiding this comment

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

We construct these in maybeCollectVars_ with the macro name coming from the macro definition, not the url.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh, that's good.

@calebcordry calebcordry merged commit c15ace5 into ampproject:master Oct 31, 2018
@calebcordry calebcordry deleted the whitelist-bug branch October 31, 2018 23:07
dreamofabear pushed a commit that referenced this pull request Oct 31, 2018
* remove args

* add test

* no str.includes
Enriqe pushed a commit to Enriqe/amphtml that referenced this pull request Nov 28, 2018
* remove args

* add test

* no str.includes
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.

None yet

5 participants