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

@@ -19,10 +19,10 @@ jest.mock("../../../../../src/languageHandler", () => ({
}));
describe("<EmbeddedPage />", () => {
it("should translate _t strings", async () => {
it.each([`"`, `'`, `&#x27;`, `&#x34;`])("should translate _t strings", async (character) => {
mocked(_t).mockReturnValue("Przeglądaj pokoje");
fetchMock.get("https://home.page", {
body: '<h1>_t("Explore rooms")</h1>',
body: `<h1>_t(${character}Explore rooms${character})</h1>`,
});
const { asFragment } = render(<EmbeddedPage url="https://home.page" />);

View File

@@ -41,3 +41,51 @@ exports[`<EmbeddedPage /> should translate _t strings 1`] = `
</div>
</DocumentFragment>
`;
exports[`<EmbeddedPage /> should translate _t strings 2`] = `
<DocumentFragment>
<div
class="undefined_guest"
>
<div
class="undefined_body"
>
<h1>
Przeglądaj pokoje
</h1>
</div>
</div>
</DocumentFragment>
`;
exports[`<EmbeddedPage /> should translate _t strings 3`] = `
<DocumentFragment>
<div
class="undefined_guest"
>
<div
class="undefined_body"
>
<h1>
Przeglądaj pokoje
</h1>
</div>
</div>
</DocumentFragment>
`;
exports[`<EmbeddedPage /> should translate _t strings 4`] = `
<DocumentFragment>
<div
class="undefined_guest"
>
<div
class="undefined_body"
>
<h1>
Przeglądaj pokoje
</h1>
</div>
</div>
</DocumentFragment>
`;