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

Ensure */ included in a template does break surrounding JS. #134

Merged
merged 1 commit into from
Dec 11, 2019

Conversation

rwjblue
Copy link
Member

@rwjblue rwjblue commented Dec 11, 2019

Prior to this a template like:

hbs`some content */`

Would emit invalid JS:

Ember.HTMLBars.template(
  /*
    some content */
  */
  {
    // some stuff emitted by actual compilation
  }
)

The comment showing the original template was added as a developer aide (makes looking at files with many inline templates such as tests much easier), but without escaping */ we risk the template content itself breaking the JS parsing within the file.

This commit ensures that */ is escaped to *\/ which avoids the issue.

Fixes ember-cli/ember-cli-htmlbars#391

Prior to this a template like:

```js
hbs`some content */`
```

Would emit invalid JS:

```js
Ember.HTMLBars.template(
  /*
    some content */
  */
  {
    // some stuff emitted by actual compilation
  }
)
```

The comment showing the original template was added as a developer aide
(makes looking at files with many inline templates such as tests much
easier), but without escaping `*/` we risk the template content itself
breaking the JS parsing within the file.

This commit ensures that `*/` is escaped to `*\/` which avoids the
issue.
@rwjblue rwjblue added the bug label Dec 11, 2019
@rwjblue rwjblue merged commit e21985f into ember-cli:master Dec 11, 2019
@rwjblue rwjblue deleted the ensure-comment-is-escaped branch December 11, 2019 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

<style> tags with CSS comments cause invalid compilation
1 participant