Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion shared/src/template/template-preprocessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ export class TemplatePreprocessor {
return { decision: { kind: 'leave', seg, reason: 'native-handlebars-path' } };
}

const safePath = path.replace(/"/g, '\\"');
const safePath = path.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
Copy link

Copilot AI Nov 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This security fix for CWE-116 (incomplete string escaping) lacks test coverage. Consider adding a test case that verifies paths containing backslashes are properly escaped. For example:

it('escapes backslashes in paths to prevent quote bypass', () => {
    const input = '{{list foo\\bar}}';
    const output = TemplatePreprocessor.preprocessTemplate(input);
    expect(output).toBe('{{list (convertFromDotNotation this "foo\\\\bar")}}');
});

it('escapes backslashes before quotes in paths', () => {
    const input = '{{nodes[\\"test\\"]}}';
    const output = TemplatePreprocessor.preprocessTemplate(input);
    expect(output).toBe('{{convertFromDotNotation this "nodes[\\\\\\"test\\\\\\"]"}}');
});

Without tests, it's difficult to verify the fix works correctly and prevent regression in the future.

Copilot uses AI. Check for mistakes.
const { kvs, positionals } = TemplatePreprocessor.splitExtrasFromString(extras);
const kvsPart = kvs.length ? ` ${kvs.join(' ')}` : '';
const posPart = positionals.length ? ` ${positionals.join(' ')}` : '';
Expand Down
Loading