Not all HTML Entities are unescaped from title and other metadata (when double-escaped by websites)
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript
- Domain
- web-dev
Research direction
Start in Readability.js at the linked unescaping function and the metadata.title call to _unescapeHtmlEntities. Reproduce the Scientific American example, then verify that double-escaped entities such as ’ are decoded in the extracted title and related metadata without unsafe parsing.
Written by the indexing model from the issue text.
Description
There is a function in the code for unescaping HTML entities:
However, it does not capture all possible HTML entities (’)
Example
On the page https://www.scientificamerican.com/podcast/episode/heres-why-actors-are-so-worried-about-ai/
There is this meta tag: <meta property="og:title" content="Here&rsquo;s Why Actors Are So Worried about AI">
The page title is extracted from it.
Special html entities are supposed to be unescaped by this function, but they are not:
The metadata.title before calling this._unescapeHtmlEntities and after is the same:
Here’s Why Actors Are So Worried about AI
Solution & Workaround
According to https://stackoverflow.com/a/34064434/8584605, a more effective (and still safe) way to unescape HTML entities would look like this:
function htmlDecode(input) {
const doc = new DOMParser().parseFromString(input, "text/html");
return doc.documentElement.textContent;
}
Until this bug is fixed, I would be using the above function to post-process the title outputted by Readability.js
- Dominant language
- JavaScript
- Stars
- 11.5k
- Forks
- 732
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from mozilla/readability
-
Difficulty 1/5 Under an hour Newbie friendliness 76/100
mozilla/readability#1026 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
mozilla/readability#997 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 58/100
mozilla/readability#1031 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 42/100
mozilla/readability#1029 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 58/100
mozilla/readability#1024 ·
All issues in mozilla/readability
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
babalae/bettergi-scripts-list#3674 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
vadimdemedes/ink#1029 ·
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
optimization optimization:agents-md-curator
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
githubnext/gh-aw-cao#13143 ·