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

Html Admin API incorrectly parses figure with a href as img #19785

Open
1 task done
PetromirDev opened this issue Mar 1, 2024 · 1 comment
Open
1 task done

Html Admin API incorrectly parses figure with a href as img #19785

PetromirDev opened this issue Mar 1, 2024 · 1 comment
Labels
bug [triage] something behaving unexpectedly

Comments

@PetromirDev
Copy link

Issue Summary

Editing a post, using Ghost API, that has a figure with a link inside replaces the link with an image.

Steps to Reproduce

  1. Have a post with the following element in the content:
<figure class=\"kg-card kg-bookmark-card\"><a class=\"kg-bookmark-container\" href=\"__GHOST_URL__/article-url/\"><div class=\"kg-bookmark-content\"><div class=\"kg-bookmark-title\">Some title</div><div class=\"kg-bookmark-description\">Some text</div><div class=\"kg-bookmark-metadata\"><img class=\"kg-bookmark-icon\" src=\"__GHOST_URL__/content/images/size/w256h256/2022/08/512pt_@1x.png\" alt=\"\"><span class=\"kg-bookmark-author\">Ghost Blog</span><span class=\"kg-bookmark-publisher\">Author</span></div></div><div class=\"kg-bookmark-thumbnail\"><img src=\"__GHOST_URL__/content/images/2023/10/cover.jpg\" alt=\"\"></div></a></figure>
  1. Run this script:
const postsRaw = await api.posts.browse({ formats: 'html', limit: 'all' })
for await (const post of postsRaw) {
    try {
		await api.posts.edit({ id: post.id, updated_at: post?.updated_at, html: post.html }, { source: 'html' })
	} catch (e) {
		console.log(`Error while updating post ${(post.id}!`, e)
	}
}
  1. The figure from above is replaced with:
<figure class=\"kg-card kg-image-card\"><img src=\"__GHOST_URL__/content/images/size/w256h256/2022/08/512pt_@1x.png\" class=\"kg-image\" alt=\"\" loading=\"lazy\"></figure>

Ghost Version

5.75.2 local, reproduced in 5.54.0 production too

Node.js Version

16.13.0

How did you install Ghost?

Followed this guide: https://ghost.org/docs/install/local/. OS: Fedora 39

Database type

SQLite3

Browser & OS version

No response

Relevant log / error output

No response

Code of Conduct

  • I agree to be friendly and polite to people in this repository
@github-actions github-actions bot added the needs:triage [triage] this needs to be triaged by the Ghost team label Mar 1, 2024
@daniellockyer daniellockyer added bug [triage] something behaving unexpectedly and removed needs:triage [triage] this needs to be triaged by the Ghost team labels Apr 1, 2024
@daniellockyer
Copy link
Member

Hey there, thank you so much for the bug report.

That does look like something that shouldn't happen! A PR to fix this issue would be very welcome 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug [triage] something behaving unexpectedly
Projects
None yet
Development

No branches or pull requests

2 participants