Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/handlebars/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ export function template(templateSpec, env) {
}

if (resultIsAllowed(result, container.protoAccessControl, propertyName)) {
if (typeof result === 'function') {
return parent[propertyName]();
}
return result;
}
return undefined;
Expand Down
11 changes: 11 additions & 0 deletions spec/security.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,17 @@ describe('security issues', function () {
})
.toCompileTo('abc');
});

it('should use a proto method to trim a string', function () {
expectTemplate('{{aString.trim}}')
.withInput({ aString: ' abc ' })
.withRuntimeOptions({
allowedProtoMethods: {
trim: true,
},
})
.toCompileTo('abc');
});
});

describe('control access to prototype non-methods via "allowedProtoProperties" and "allowProtoPropertiesByDefault', function () {
Expand Down