Skip to content

Commit

Permalink
ali's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
William Chou committed Jun 15, 2017
1 parent e0b7047 commit 143d929
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/service/standard-actions-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ import {OBJECT_STRING_ARGS_KEY} from '../service/action-impl';
import {Layout, getLayoutClass} from '../layout';
import {actionServiceForDoc, urlReplacementsForDoc} from '../services';
import {bindForDoc} from '../services';
import {computedStyle, getStyle, toggle} from '../style';
import {dev, user} from '../log';
import {registerServiceBuilderForDoc} from '../service';
import {historyForDoc} from '../services';
import {isProtocolValid} from '../url';
import {registerServiceBuilderForDoc} from '../service';
import {resourcesForDoc} from '../services';
import {computedStyle, getStyle, toggle} from '../style';
import {vsyncFor} from '../services';

/**
Expand Down Expand Up @@ -136,6 +137,9 @@ export class StandardActions {
return;
}
const url = invocation.args['url'];
if (!isProtocolValid(url)) {
return;
}
const expandedUrl = this.urlReplacements_.expandUrlSync(url);
const node = invocation.target;
const win = (node.ownerDocument || node).defaultView;
Expand Down
6 changes: 6 additions & 0 deletions test/functional/test-standard-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ describes.sandboxed('StandardActions', {}, () => {
standardActions.handleAmpTarget(invocation);
expect(win.location).to.equal('http://bar.com');
expect(expandUrlStub.calledOnce);

// Invalid protocols should fail.
invocation.args.url = /*eslint no-script-url: 0*/ 'javascript:alert(1)';
standardActions.handleAmpTarget(invocation);
expect(win.location).to.equal('http://bar.com');
expect(expandUrlStub.calledOnce);
});

it('should implement goBack', () => {
Expand Down

0 comments on commit 143d929

Please sign in to comment.