Skip to content

Commit 17da539

Browse files
committed
fix: escape Qwen command carriage returns
1 parent 0f1f510 commit 17da539

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/core/command-generation/adapters/qwen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { transformToHyphenCommands } from '../../../utils/command-references.js'
1515
function escapeYamlValue(value: string): string {
1616
const needsQuoting = /[:\n\r#{}[\],&*!|>'"%@`]|^\s|\s$/.test(value);
1717
if (needsQuoting) {
18-
const escaped = value.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\n/g, '\\n');
18+
const escaped = value.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\n/g, '\\n').replace(/\r/g, '\\r');
1919
return `"${escaped}"`;
2020
}
2121
return value;

test/core/command-generation/adapters.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,16 @@ describe('command-generation/adapters', () => {
611611
const output = qwenAdapter.formatFile(contentWithSpecialChars);
612612
expect(output).toContain('description: "Fix: regression in \\"auth\\" feature"');
613613
});
614+
615+
it('should escape carriage returns in description', () => {
616+
const contentWithCarriageReturn: CommandContent = {
617+
...sampleContent,
618+
description: 'Line 1\rLine 2',
619+
};
620+
621+
const output = qwenAdapter.formatFile(contentWithCarriageReturn);
622+
expect(output).toContain('description: "Line 1\\rLine 2"');
623+
});
614624
});
615625

616626
describe('piAdapter', () => {

0 commit comments

Comments
 (0)