Ghost: Certain code tag content breaks AMP output

Issue Summary

Adding '$example$' to the markdown truncates the AMP output before the second $ causing broken browser rendering through missing closing tags.

screen shot 2018-07-04 at 13 33 07

To Reproduce

  1. Create a new post and set the content to:
Testing

`'$example$'` asdf

123
  1. Publish the post and open the AMP version on the blog front-end. Note the broken display and missing content after '$example.

The HTML output is clearly malformed. the trailing $' is removed and the rest of the helper output is added to the bottom of the post with the final section duplicated:

screen shot 2018-07-04 at 14 07 19

This results in the browser injecting lots of extra <code></code> tags to try and deal with the malformed HTML.

Removing the SafeString call so that handlebars outputs the raw string appears to show that there’s a nested async helper issue:

<div class="kg-card-markdown">
  <p>Testing</p>
  <p>
    <code>'$example__aSyNcId_<_ZziCMbqm__#x27;</code>
    asdf
  </p>
  <p>123</p>
</div>

Narrowing the troublesome content down it appears to be caused by a trailing $ or $' in any element. This can be demonstrated with simply putting $ as the only markdown content in a post.

Technical details:

  • Ghost Version: 1.24.7
  • Node Version: 8.10.0
  • Browser/OS: n/a
  • Database: SQLite

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (14 by maintainers)

Commits related to this issue

Most upvoted comments

Opened a PR. https://github.com/barc/express-hbs/pull/149

Once it is merged and published in a new version we can open a PR to update the version in this repo.

Still waiting for the permissions to publish the merge and then we can make sure this fixes this issue by testing out the new version here.

@lunaticmonk I think you’re on the right track. That’s where I saw this glitch happening too. I couldn’t find a solution within the sanitize-html module tho. Would be super nice, if you’d find a solution here 🤗