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

change concat to return a string #156

Open
wants to merge 2 commits into
base: 2.x
Choose a base branch
from
Open

change concat to return a string #156

wants to merge 2 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Apr 12, 2019

Currently concat returns safeString. We are not sure if we receive safe string into the method. We might turn a safe string that will be escaped into an unsafe one string that won’t be checked before display, allowing malicious code injection.

We have an issue open related to contact returned value (bigcommerce/cornerstone#1115):
{{occurrences '|default|product|blog_post|' (concat page_type '|')}}
occurrences expects to receive a string but since concat return safe string the method cause timeout.

@@ -6,8 +6,13 @@
* {{@lang (concat 'products.reviews.rating.' this) }}
*/
function helper(paper) {
paper.handlebars.registerHelper('concat', function (value, otherValue) {
return new paper.handlebars.SafeString(value + otherValue);
paper.handlebars.registerHelper('concat', function (value, otherValue, returnSafeString = true) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would rename this parameter to returnUnsafe and default it to false, which will preserve existing behavior.

@@ -0,0 +1,4917 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't check in this file since this is a library included by other applications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant