Skip to content

Commit 8c38a33

Browse files
Merge pull request #4930 from FlowFuse/yndira/fix-flow-html-escaping
escape HTML characters in flow JSON to prevent htmlmin parse errors
2 parents a23df06 + dc76664 commit 8c38a33

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/_data/integrations.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ module.exports = async () => {
137137
}
138138
});
139139

140-
let sanitizedFlow = flowContent;
140+
const escapeForHtml = (s) => s.replace(/&/g, '\\u0026').replace(/</g, '\\u003c').replace(/>/g, '\\u003e');
141+
let sanitizedFlow = escapeForHtml(flowContent);
141142
try {
142143
const flowJson = JSON.parse(flowContent);
143144
const sanitizeNode = (n) => {
@@ -152,7 +153,10 @@ module.exports = async () => {
152153
} else {
153154
sanitizeNode(flowJson);
154155
}
155-
sanitizedFlow = JSON.stringify(flowJson);
156+
sanitizedFlow = JSON.stringify(flowJson)
157+
.replace(/&/g, '\\u0026')
158+
.replace(/</g, '\\u003c')
159+
.replace(/>/g, '\\u003e');
156160
} catch (_) { /* keep original if not valid JSON */ }
157161

158162
return {

0 commit comments

Comments
 (0)