Skip to content

OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security

fix(knowledge-base): keep non-breaking hyphens in DOCX text (#2272)

Lanre Shittuf1aa3ac9e00d
diff --git a/sdk/typescript/src/knowledge-base.ts b/sdk/typescript/src/knowledge-base.ts
index 38d3dda36..bbbb04745 100644
--- a/sdk/typescript/src/knowledge-base.ts
+++ b/sdk/typescript/src/knowledge-base.ts
@@ -378,6 +378,7 @@ function extractDocx(path: string, bytes: Uint8Array): string {
else if (type === "end") finishField(true);
} else if (localName === "br" || localName === "cr") append("\n");
else if (localName === "tab") append("\t");
+ else if (localName === "noBreakHyphen") append("-");
});
parser.on("closetag", ({ name, isSelfClosing }) => {
const localName = name.split(":").at(-1);
diff --git a/sdk/typescript/tests-ts/api-provider-isolation.test.ts b/sdk/typescript/tests-ts/api-provider-isolation.test.ts
index 9b7a71f19..bfbfa2b22 100644
--- a/sdk/typescript/tests-ts/api-provider-isolation.test.ts
+++ b/sdk/typescript/tests-ts/api-provider-isolation.test.ts
@@ -881,7 +881,6 @@ for (const mode of ["standard", "deep"] as const) {
await client.close();
}
},
- 30_000,
);
}
diff --git a/sdk/typescript/tests-ts/knowledge-base.test.ts b/sdk/typescript/tests-ts/knowledge-base.test.ts
index a73699f4c..03611b724 100644
--- a/sdk/typescript/tests-ts/knowledge-base.test.ts
+++ b/sdk/typescript/tests-ts/knowledge-base.test.ts
@@ -509,6 +509,10 @@ describe("scan knowledge bases", () => {
join(root, "self-closing-tab.docx"),
docx("User", "Permission", "<w:tab/>"),
);
+ await writeFile(
+ join(root, "non-breaking-hyphen.docx"),
+ docx("X", "Frame-Options", "<w:noBreakHyphen/>"),
+ );
await writeFile(
join(root, "tracked-change.docx"),
docxBody(
@@ -544,6 +548,7 @@ describe("scan knowledge bases", () => {
expect(documents).toContain("Authentication\nReview sessions\n");
expect(documents).toContain("Role\tCapability\n");
expect(documents).toContain("User\tPermission\n");
+ expect(documents).toContain("X-Frame-Options\n");
expect(documents).toContain("Admin API is internal only\n");
expect(documents).toContain("Rotate keys. \nAudit weekly.\n");
expect(documents).toContain("See the runbook\n");