-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
HTML attribute quotes are switched from '->" on published posts #10793
Comments
@billyzoellers how are you inspecting the code output? I've just checked this and I can't reproduce. In Chrome's web inspector it appears as though there are double quotes because its inspector automatically changes them as it always uses double quotes for attribute values: However, looking at the raw data in the response from Ghost the single quotes are preserved: |
@kevinansfield I as looking in view source in Chrome. I see the same issue in view source in Firefox as well. 'data-options' is being parsed by a js script that is throwing an error due to the quotes, so I believe the 'bad' HTML is making it to that js script somehow. I have confirmed that if I hardcode the HTML onto the .hbs template, things work as expected - and when hardcoded, view source shows the single quotes as expected. |
Hmm, this is very strange. I can only see the It appears this is not related to the editor at all, the data saved in the HTML card inside mobiledoc is always correct, as is the rendered |
Scratch that, it's in the API layer rather than the handlebars layer. When performing API requests to the v2 Admin/Content APIs for the post in question the quotes are returned incorrectly in the
The key point being The data in the database is correct: <!--kg-card-begin: html--><span class="text-success" data-toggle="typed" data-options='{"strings": ["item1", "item2"]}'></span><!--kg-card-end: html--><p>Testing</p> The v0.1 Public API does not mangle quotes. |
@kevinansfield Interesting! I can confirm that draft mode works for me as well. |
Adding some extra context, the mangling is much worse if you try to escape the quotes with backslashes... html card content: <span class="text-success" data-toggle="typed" data-options="{\"strings\": [\"item1\", \"item2\"]}"></span>. becomes: <!--kg-card-begin: html--><span class="text-success" data-toggle="typed" data-options="{\" strings\":="" [\"item1\",="" \"item2\"]}"=""></span>.<!--kg-card-end: html--> @billyzoellers the core team is unlikely to get to this until at least next Monday but maybe a contributor will get there first 😄 In the meantime you can workaround the issue by using html-escape codes if that's possible (html escaped chars appear as the actual char to JS when reading attributes): <span class="text-success" data-toggle="typed" data-options="{"strings": ["item1", "item2"]}"></span>. |
This issue is now being tracked in our SDK package repo TryGhost/SDK#124 |
refs TryGhost#10793 - fixes `urlUtils.htmlRelativeToAbsolute` mangling attribute quote styles and removing indentation
refs #10793 - fixes `urlUtils.htmlRelativeToAbsolute` mangling attribute quote styles and removing indentation
This issue was resolved via #11027 |
Issue Summary
Running Ghost 2.23.4/2.5.0 on Ubuntu - the exact HTML I enter into the editor is modified on the frontend page.
To Reproduce
I entered the following HTML block into the editor - note the single quotes.
<span class="text-success" data-toggle="typed" data-options='{"strings": ["item1", "item2"]}'></span>.
On the front end, single quotes are reflected as double quotes
<!--kg-card-begin: html--><span class="text-success" data-toggle="typed" data-options="{"strings": ["item1", "item2"]}"></span>.<!--kg-card-end: html-->
Technical details:
The text was updated successfully, but these errors were encountered: