Skip to content

Commit 6fe2d61

Browse files
CopilotFDiskas
andcommitted
Apply source code formatting with biome
Co-authored-by: FDiskas <[email protected]>
1 parent 586c6f4 commit 6fe2d61

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

src/schema-parser/schema-formatters.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,20 @@ export class SchemaFormatters {
106106
if (!content) return "";
107107
// Escape */ sequences to prevent breaking out of JSDoc comments
108108
// Note: /* sequences inside JSDoc comments are harmless and don't need escaping
109-
return content
110-
.replace(/\*\//g, "*\\/");
109+
return content.replace(/\*\//g, "*\\/");
111110
};
112111

113112
formatDescription = (description, inline) => {
114113
if (!description) return "";
115114

116115
// Check if content is already escaped - if so, don't escape again
117-
const isAlreadyEscaped = description.includes('*\\/');
118-
116+
const isAlreadyEscaped = description.includes("*\\/");
117+
119118
// Escape JSDoc comment characters only if not already escaped
120-
const escapedDescription = isAlreadyEscaped ? description : this.escapeJSDocContent(description);
121-
119+
const escapedDescription = isAlreadyEscaped
120+
? description
121+
: this.escapeJSDocContent(description);
122+
122123
const hasMultipleLines = escapedDescription.includes("\n");
123124

124125
if (!hasMultipleLines) return escapedDescription;

tests/spec/jsdoc-escaping/basic.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ describe("jsdoc-escaping", async () => {
3131
expect(content).not.toMatch(/\*\/ alert\(/); // No unescaped code injection
3232
expect(content).not.toMatch(/\*\/ window\./); // No unescaped window manipulation
3333
expect(content).not.toMatch(/\*\/ dangerous content \*\//); // No unescaped dangerous content
34-
34+
3535
// Check that only necessary escaping is applied
36-
expect(content).toMatch(/\*\\\//); // Should contain escaped */
36+
expect(content).toMatch(/\*\\\//); // Should contain escaped */
3737
expect(content).not.toMatch(/\\\*\//); // Should NOT contain escaped /* sequences
38-
38+
3939
// Check that alert and window are escaped
4040
expect(content).toMatch(/alert\('XSS'\)/); // Should still contain the content but safely escaped
4141
expect(content).toMatch(/window\.location/); // Should still contain but safely escaped
42-
42+
4343
expect(content).toMatchSnapshot();
4444
});
45-
});
45+
});

tests/spec/jsdoc-escaping/schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"description": "The ID of the information record. Contains **/ dangerous content /** here."
3737
},
3838
"title": {
39-
"type": "string",
39+
"type": "string",
4040
"description": "Title field with */ and /* characters that could break comments"
4141
},
4242
"content": {
@@ -47,4 +47,4 @@
4747
}
4848
}
4949
}
50-
}
50+
}

0 commit comments

Comments
 (0)