-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix($compile): prevent inlined JSON values in directive templates from being broken by a wrong replacement of '}}' with the user-defined endSymbol. #6493
Conversation
…m being broken by a wrong replacement of '}}' with the user-defined endSymbol.
Thanks for the PR! Please check the items below to help us merge this faster. See the contributing docs for more information.
If you need to make changes to your pull request, you can update the commit with Thanks again for your help! |
I'm sorry, but I wasn't able to verify your Contributor License Agreement (CLA) signature. CLA signature is required for any code contributions to AngularJS. Please sign our CLA and ensure that the CLA signature email address and the email address in this PR's commits match. If you signed the CLA as a corporation, please let us know the company's name. Thanks a bunch! PS: If you signed the CLA in the past then most likely the email addresses don't match. Please sign the CLA again or update the email address in the commit of this PR. |
I've signed as a corporation. I've filled, scanned and emailed the form, as expected. Thanks! |
02dc2aa
to
fd2d6c0
Compare
cad9560
to
f294244
Compare
e8dc429
to
e83fab9
Compare
var startSymbol = $interpolate.startSymbol(), | ||
endSymbol = $interpolate.endSymbol(), | ||
denormalizeTemplate = (startSymbol == '{{' || endSymbol == '}}') | ||
? identity | ||
: function denormalizeTemplate(template) { | ||
return template.replace(/\{\{/g, startSymbol).replace(/}}/g, endSymbol); | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we did it like this instead:
template.replace(/\{\{(.*?)\}\}/g, function(_, expr) {
return startSymbol + expr + endSymbol;
});
I could be wrong (and probably am slightly off on the syntax here), but I would expect this to work a lot better, and be significantly less code.
@fredericbonjour could you also rebase this? thanks |
4dd5a20
to
998c61c
Compare
…rd interpolation symbols In order to support third party modules that do not use the same interpolation symbols as the main app, we implemented denormalization (see dfe9983). This required that 3rd party modules always used the standad `{{` and `}}` interpolation symbols, so that we could correctly denormalise them to the current app's symbols. The problem with this became apparent when an app template using new symbols inadvertently contained one of the standard interpolation symbols. E.g. `<div data-context='{"context":{"id":3,"type":"page"}}">` The double closing curly braces were being incorrectly denormalised. This commit fixes this by allowing the compiler to be configured to know what symbols are being used in templates from a given module. Now modules can specify that what interpolation symbols they use and the compiler will denormalize appropriately. Closes angular#6493 Closes angular#6453
…rd interpolation symbols In order to support third party modules that do not use the same interpolation symbols as the main app, we implemented denormalization (see dfe9983). This required that 3rd party modules always used the standad `{{` and `}}` interpolation symbols, so that we could correctly denormalise them to the current app's symbols. The problem with this became apparent when an app template using new symbols inadvertently contained one of the standard interpolation symbols. E.g. `<div data-context='{"context":{"id":3,"type":"page"}}">` The double closing curly braces were being incorrectly denormalised. This commit fixes this by allowing the compiler to be configured to know what symbols are being used in templates from a given module. Now modules can specify that what interpolation symbols they use and the compiler will denormalize appropriately. Closes angular#6493 Closes angular#6453
Request Type: bug
How to reproduce:
Result: the '}}' at the end of the embedded JSON data gets transformed to the endSymbol defined by the developer.
Component(s): $compile
Impact: small
Complexity: medium
This issue is related to:
Detailed Description:
Other Comments:
Discussion about this in a previous PR: #6453