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.
To Reproduce
- Create a new post and set the content to:
Testing
`'$example$'` asdf
123
- 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:
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
- 🐛 Fixed AMP output when there is a trailing '$' closes #9716 This was caused by a bug in express-hbs, which has more explanation here: https://github.com/TryGhost/Ghost/issues/9716#issuecomment-414... — committed to allouis/Ghost by allouis 5 years ago
- 🐛 Fixed AMP output when there is a trailing '$' closes #9716 This was caused by a bug in express-hbs, which has more explanation here: https://github.com/TryGhost/Ghost/issues/9716#issuecomment-414... — committed to TryGhost/Ghost by allouis 5 years ago
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-htmlmodule tho. Would be super nice, if you’d find a solution here 🤗