Question

This is a pretty specific problem and I believe that I have found the source of the error, but am clueless as to how to solve it. Basically, I am trying to deploy an application to Heroku that allows users to download their notes in PDF form (for which I am using the wicked_pdf gem). The PDF is being generated normally, but when it is returned, there is a long string of meaningless characters where there ought to be notes. The text in the PDF begins like this:

",rE:!0,sL:"javascript"}},{b:"",sL:"vbscript"} ...

and continues for several pages.It turns out that this code is part of the highlight.js library that I am using for syntax highlighting. When I went digging through the minified source code for the substring shown above, I discovered that it is preceded by the following:

... ,starts:{e:"<\/script>",rE:true,sL:"javascript"} ...

specifically starts:{e:"<\/script>", which seems to be being interpreted as a literal closing tag, resulting in the remaining Javascript being rendered as text. I am wondering if anyone has encountered this problem with heroku before and what steps I can take to prevent this from happening.

Was it helpful?

Solution

I found a solution, if not an answer to this problem, was to outsource the Javascript asset serving of highlight.js to the cloudflare cdn. While this does not answer the original question of why this incorrect escaping was happening, it did ultimately end up solving my pdf rendering problem.

That being said, I would still be interested in why this problem arose in the first place. Feel free to lend me your insight should you have any.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top