Skip to content

Commit 67d5fe0

Browse files
Copilotdata-douser
andauthored
Replace sanitizeForInlineCode with CommonMark-compliant markdownInlineCode
- markdownInlineCode() uses a fence length = maxRun+1 per CommonMark spec, preserving the original string (no information loss from backtick→apostrophe) - Normalises CR/CRLF to LF before wrapping (inline spans can't span lines) - Export markdownInlineCode for testability - Add 6 unit tests for markdownInlineCode (plain text, single/double backtick, CRLF normalisation, backtick-only values) - Add regression test for formatValidationError with backtick in received value - Add regression test for resolvePromptFilePath warning with backtick in path Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com> Agent-Logs-Url: https://github.com/advanced-security/codeql-development-mcp-server/sessions/ec7c534b-93ac-40e5-bcb6-023bc7496940
1 parent a4add76 commit 67d5fe0

File tree

4 files changed

+112
-14
lines changed

4 files changed

+112
-14
lines changed

server/dist/codeql-development-mcp-server.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64468,8 +64468,22 @@ var SUPPORTED_LANGUAGES = [
6446864468
"ruby",
6446964469
"swift"
6447064470
];
64471-
function sanitizeForInlineCode(value) {
64472-
return value.replace(/`/g, "'").replace(/\r?\n|\r/g, " ");
64471+
function markdownInlineCode(value) {
64472+
const normalized = value.replace(/\r\n?/g, "\n");
64473+
let maxRun = 0;
64474+
let currentRun = 0;
64475+
for (const ch of normalized) {
64476+
if (ch === "`") {
64477+
currentRun += 1;
64478+
if (currentRun > maxRun) {
64479+
maxRun = currentRun;
64480+
}
64481+
} else {
64482+
currentRun = 0;
64483+
}
64484+
}
64485+
const fence = "`".repeat(maxRun + 1);
64486+
return `${fence}${normalized}${fence}`;
6447364487
}
6447464488
async function resolvePromptFilePath(filePath, workspaceRoot) {
6447564489
if (!filePath || filePath.trim() === "") {
@@ -64506,7 +64520,7 @@ async function resolvePromptFilePath(filePath, workspaceRoot) {
6450664520
} catch {
6450764521
return {
6450864522
resolvedPath: absolutePath,
64509-
warning: `\u26A0 **File path** \`${sanitizeForInlineCode(filePath)}\` **does not exist.** Resolved to: \`${sanitizeForInlineCode(absolutePath)}\``
64523+
warning: `\u26A0 **File path** ${markdownInlineCode(filePath)} **does not exist.** Resolved to: ${markdownInlineCode(absolutePath)}`
6451064524
};
6451164525
}
6451264526
return { resolvedPath: absolutePath };
@@ -64602,7 +64616,7 @@ function formatValidationError(promptName, error2) {
6460264616
if (issue2.code === "invalid_enum_value" && "options" in issue2) {
6460364617
const opts = issue2.options.join(", ");
6460464618
lines.push(
64605-
`- **\`${field}\`**: received \`${sanitizeForInlineCode(String(issue2.received))}\` \u2014 must be one of: ${opts}`
64619+
`- **\`${field}\`**: received ${markdownInlineCode(String(issue2.received))} \u2014 must be one of: ${opts}`
6460664620
);
6460764621
} else if (issue2.code === "invalid_type") {
6460864622
lines.push(

0 commit comments

Comments
 (0)