Skip to content

Commit ca0792d

Browse files
author
Tim Roes
authored
Prevent usage of dangerouslySetInnerHTML (#22201)
1 parent 9757937 commit ca0792d

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

airbyte-webapp/.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ module.exports = {
8484
},
8585
],
8686
"jest/consistent-test-it": ["warn", { fn: "it", withinDescribe: "it" }],
87+
"react/no-danger": "error",
8788
"react/jsx-boolean-value": "warn",
8889
"react/jsx-curly-brace-presence": "warn",
8990
"react/jsx-fragments": "warn",

airbyte-webapp/src/components/connection/CatalogTree/next/CatalogTreeTableCell.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ const TooltipText: React.FC<{ textNodes: Element[] }> = ({ textNodes }) => {
2727
return null;
2828
}
2929
const text = textNodes.map((t) => decodeURIComponent(t.innerHTML)).join(" | ");
30+
// This is not a safe use, and need to be removed still.
31+
// https://github.com/airbytehq/airbyte/issues/22196
32+
// eslint-disable-next-line react/no-danger
3033
return <div dangerouslySetInnerHTML={{ __html: text }} />;
3134
};
3235

airbyte-webapp/src/components/ui/TextWithHTML/TextWithHTML.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,8 @@ export const TextWithHTML: React.FC<TextWithHTMLProps> = ({ text, className }) =
2626
},
2727
});
2828

29+
// Since we use `sanitize-html` above to sanitize this string from all dangerous HTML, we're safe to
30+
// set this here via `dangerouslySetInnerHTML`
31+
// eslint-disable-next-line react/no-danger
2932
return <span className={className} dangerouslySetInnerHTML={{ __html: sanitizedHtmlText }} />;
3033
};

0 commit comments

Comments
 (0)