Skip to content

Commit 992e032

Browse files
committed
test(webapp): assert xml parser accepts aws entity names
1 parent e3de592 commit 992e032

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { readFileSync } from "node:fs";
2+
import { dirname, join } from "node:path";
3+
import { fileURLToPath } from "node:url";
4+
import { describe, expect, it } from "vitest";
5+
6+
const rootPackageJson = JSON.parse(
7+
readFileSync(join(dirname(fileURLToPath(import.meta.url)), "../../../package.json"), "utf8")
8+
) as {
9+
pnpm: { overrides: Record<string, string> };
10+
};
11+
12+
describe("fast-xml-parser aws sdk compatibility", () => {
13+
it("pins 5.x past the 5.7 window that rejects addEntity('#xD')", () => {
14+
expect(rootPackageJson.pnpm.overrides["fast-xml-parser@>=5 <5.8.0"]).toBe("^5.8.0");
15+
});
16+
17+
it("accepts the character-reference entities @aws-sdk/xml-builder registers", async () => {
18+
const { XMLParser } = await import("fast-xml-parser");
19+
const parser = new XMLParser({ htmlEntities: true });
20+
21+
expect(() => {
22+
parser.addEntity("#xD", "\r");
23+
parser.addEntity("#10", "\n");
24+
parser.parse("<a>1</a>", true);
25+
}).not.toThrow();
26+
});
27+
});

0 commit comments

Comments
 (0)