zooniverse / front-end-monorepo

A rebuild of the front-end for zooniverse.org
https://www.zooniverse.org
Apache License 2.0
104 stars 30 forks source link

HTML entities can crash Markdown components ("document is not defined") #3679

Closed shaunanoordin closed 1 year ago

shaunanoordin commented 2 years ago

Uncategorised Bug?

Package: app-project, possibly others Affects: ⚠️ anything that uses Markdown, e.g. Project About Team page, About Project, Announcements banner, etc

The problem: if a Markdown component tries to render an escaped HTML entity such as & (ampersand), it crashes the whole page.

Dev Notes

Some notes from our investigation:

Scenario 1: literal symbols in the Markdown text Play "Dungeons & Dragons" ©, it's > Cthulhu ♥

Scenario 2: proper HTML entities Play "Dungeons & Dragons" ©, it's > Cthulhu ♥

Scenario 3?: sorta-proper HTML entities Play &quotDungeons &amp Dragons&quot &copy, it's &gt Cthulhu &hearts

So anyway, it looks like HTML entities only crash our page if they're bracketed by both & and ; , but ALL HTML entities can crash us (not just the & )

Status

Unknown priority.

EDIT: possibly solved by #3678

eatyourgreens commented 1 year ago

Was this closed by #3678? Entities still raise a 'document is not defined' error, but it doesn't crash the page any more.

shaunanoordin commented 1 year ago

I say let's close this issue for now, as the important thing is that the pages aren't crashing. 👌

(Context for anyone who didn't read #3678: instead of crashing the page, HTML entities in Markdown now render as <p>document is not defined</p> on the page, and only if you have JS disabled.)

The only ways I can think of that the new "document is not defined" error could remotely be a problem are if (1) people notice "document is not defined" as the project's preview in their, erm, Google search results? (super unlikely, since our meta-description tags & etc now render fine)) or (2) we have a new logging system that automatically picks up the flood of console.errors in the dev log.

eatyourgreens commented 1 year ago

@shaunanoordin People will see 'document is not defined' when the page loads in their browser. https://www.zooniverse.org/projects/mariaedgeworthletters/maria-edgeworth-letters/about/team

https://user-images.githubusercontent.com/59547/191921740-f59175d5-62a0-4367-b07d-ed27d26d2838.mov