Skip to content

Commit

Permalink
fix: STRF-12532 Set Access has been denied to resolve the property me…
Browse files Browse the repository at this point in the history
…ssage to info level
  • Loading branch information
jairo-bc committed Oct 7, 2024
1 parent cb24ee3 commit e78963f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,8 @@ class HandlebarsRenderer {
let method = this.handlebars.logger.methodMap[level];
if (typeof this.logger[method] !== 'function') {
method = 'log';
} else if (this._overrideHandlebarsAccessDeniedToPropertyMessageLevel(...message)) {
method = 'info';
}
this.logger[method](...message);
}
Expand All @@ -403,6 +405,10 @@ class HandlebarsRenderer {
}
}

_overrideHandlebarsAccessDeniedToPropertyMessageLevel(message) {
return message.includes('Handlebars: Access has been denied to resolve the property');
}

/**
*
* @param {String} level
Expand Down
8 changes: 8 additions & 0 deletions spec/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,14 @@ describe('logging', () => {
done();
});

it('should check that property access denied message is set as info', done => {
const renderer = new HandlebarsRenderer({}, {}, 'v4', logger);
const result = renderer.renderString("{{aString.trim}}", { aString: " abc " });
expect(result).to.equal({});
expect(logger.info.calledWith('Handlebars: Access has been denied to resolve the property "trim" because it is not an "own property" of its parent.\n' + 'You can add a runtime option to disable the check or this warning:\n' + 'See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details'))
.to.equal(true);
done();
});
});

// STRF-12276
Expand Down

0 comments on commit e78963f

Please sign in to comment.