Skip to content

Commit

Permalink
Property check for getDefaultActionAlias on node (#20249)
Browse files Browse the repository at this point in the history
* check for method on node

* !! to coerce string to bool to guard against empty string default alias

* choumx comment

* choumx comment

* comment
  • Loading branch information
alabiaga committed Jan 11, 2019
1 parent efc7d72 commit eb331c4
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/service/action-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -745,22 +745,23 @@ export class ActionService {
* @private
*/
function isActionWhitelisted_(invocation, whitelist) {
const {method, node, tagOrTarget} = invocation;
const tagOrTargetCalled = tagOrTarget.toLowerCase();
let methodCalled = method.toLowerCase();
const defaultActionAlias = node.getDefaultActionAlias();
const calledByDefaultActionAndHasDefaultAlias =
method == DEFAULT_ACTION && (node && defaultActionAlias);
// If called via default action 'activate', check the whitelist
// against the default action alias.
if (calledByDefaultActionAndHasDefaultAlias) {
methodCalled = defaultActionAlias.toLowerCase();
let {method} = invocation;
const {node, tagOrTarget} = invocation;
// Use alias if default action is invoked.
if (method === DEFAULT_ACTION
&& (typeof node.getDefaultActionAlias == 'function')) {
method = node.getDefaultActionAlias();
}

return whitelist.some(({tagOrTarget, method}) => {
return (tagOrTarget === '*'
|| tagOrTargetCalled == tagOrTarget.toLowerCase()) &&
(methodCalled == method.toLowerCase());
const lcMethod = method.toLowerCase();
const lcTagOrTarget = tagOrTarget.toLowerCase();
return whitelist.some(w => {
if (w.tagOrTarget.toLowerCase() === lcTagOrTarget
|| (w.tagOrTarget === '*')) {
if (w.method.toLowerCase() === lcMethod) {
return true;
}
}
return false;
});
}

Expand Down

0 comments on commit eb331c4

Please sign in to comment.