Check HTML-encoded quotes when handling translations for embedded pages (such as welcome.html) (#30743)

* Check HTML encoding on embedded page

* Add tests

* lint
This commit is contained in:
Will Hunt
2025-09-11 11:45:35 +01:00
committed by GitHub
parent a69ce3f64e
commit 1c1f1435be
3 changed files with 55 additions and 3 deletions

View File

@@ -72,7 +72,11 @@ export default class EmbeddedPage extends React.PureComponent<IProps, IState> {
return;
}
let body = (await res.text()).replace(/_t\(['"]([\s\S]*?)['"]\)/gm, (match, g1) => this.translate(g1));
// Replace '," and HTML encoded variants
let body = (await res.text()).replace(
/_t\((?:['"]|(?:&#(?:34|27);))([\s\S]*?)(?:['"]|(?:&#(?:34|27);))\)/gm,
(match, g1) => this.translate(g1),
);
if (this.props.replaceMap) {
Object.keys(this.props.replaceMap).forEach((key) => {