isomerpages / isomercms-backend

A static website builder and host for the Singapore Government
5 stars 1 forks source link

fix(utils): change order of ops and rec sanitization #680

Closed seaerchin closed 1 year ago

seaerchin commented 1 year ago

Problem

the problem is that sanitizing in special pages (homepage, contact us, nav) leads to html tags being removed. though this is expected behaviour, it destructively interferes with user edits.

an example of this is when the user uses to direct users to their internal link; this gets removed sadly and causes errors when we do yaml.parse post sanitization.

Solution

sanitize the values post parsing rather than treating the yaml as a raw blob

Dependencies

Upgraded yaml from 1.x to 2.x in order to use the reviver/replacer functionality. This operates on the value post parsing, which is what we desire. See here for more info on this.

This is a breaking change but we only use .parse (verified by global search on codebase) so this a safe upgrade for us