Skip to content

Conversation

markpeek
Copy link
Contributor

As the description is taken from the raw text of the document it can contain some HTML reserved characters. This change will escape the description string to use HTML entities instead.

This was causing an error when generating a sphinx EPUB document.

As the description is taken from the raw text of the document it
can contain some HTML reserved characters. This change will escape
the description string to use HTML entities instead.
@TheTripleV
Copy link
Collaborator

I wonder what users of og:desc do. Like how slack and discord embeds display the escaped version. It should be fine but just wanna check.

@markpeek
Copy link
Contributor Author

Thanks @TheTripleV for looking into the PR. I created a quick reproduction of the issue via this repo in case you wanted to look at it yourself.

@methane
Copy link

methane commented May 7, 2024

I want to remove all opengraph meta tag from ePub.
Would you check if app.builder.embedded: return in html_page_context?

@m-aciek
Copy link
Contributor

m-aciek commented Jul 14, 2025

Apparently html.escape() converts only &, <, >," and '. (Though it should be enough.)

I wonder what users of og:desc do. Like how slack and discord embeds display the escaped version. It should be fine but just wanna check.

I've uploaded following file to a server:

<!doctype html>
<html lang="en">
  <head>
    <title>test</title>
    <meta name="robots" content="noindex">
    <meta property="og:description" content="Rob &amp; Bob &lt;[email protected]&gt; wrote: &#x27;Please replace &quot;Hi&quot; with &quot;Hello&quot;&#x27;" />
  </head>
</html>

Both https://opengraph.dev and https://opengraph.xyz render them correctly, with rendered HTML entities. Facebook debugger was unable to fetch the data in reasonable time. LinkedIn post inspector render the entities correctly in the properties (the card preview doesn't load description content, so no preview screenshot).

Zrzut ekranu 2025-07-14 o 02 44 04

Also a message shared on Discord loaded rendered entities (previous version of it, with only &lt; and &gt; escapes):
Zrzut ekranu 2025-07-14 o 02 12 00

On Slack my links didn't convert to a preview.

I can share the URL I used with anyone interested, privately.

I believe this PR should fix the EPUB rendering issue.

AA-Turner and others added 4 commits August 3, 2025 18:14
@AA-Turner AA-Turner merged commit 72b7f5a into sphinx-doc:0.x Aug 3, 2025
23 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants