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

escape dollar signs in component.js #params #14

Merged
merged 2 commits into from
Jan 13, 2017
Merged

escape dollar signs in component.js #params #14

merged 2 commits into from
Jan 13, 2017

Conversation

gannoncurran
Copy link
Contributor

@gannoncurran gannoncurran commented Jan 13, 2017

Escape dollar signs passed to t() function.

This fixes unexpected output for strings that contain dollar signs passed to t() via the params object. These can be interpreted by Javascript's String.prototype.replace() as replacement patterns.

Addresses issue #13

@gannoncurran gannoncurran mentioned this pull request Jan 13, 2017
@francescarpi francescarpi merged commit 6afb371 into APSL:master Jan 13, 2017
@gannoncurran gannoncurran deleted the b/ie11-dollarsign-escape branch January 13, 2017 18:31
text = text.replace(reg, _params[k]);
// Escape possible '$' in params to prevent unexpected behavior with .replace()
// especially important for IE11, which misinterprets '$0' as a regex command
var param = _params[k].replace(/\$/g, '$$$$');
Copy link
Contributor

Choose a reason for hiding this comment

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

This assumes that the param value is going to be a string when before you could pass a number.

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

Successfully merging this pull request may close these issues.

3 participants