Skip to content

Commit

Permalink
writeDiffRangeDataExtensionPack: escape special characters in filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
cklin committed Jan 13, 2025
1 parent 52315a9 commit 3548ff5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/analyze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,11 @@ extensions:
let data = ranges
.map(
(range) =>
` - ["${range.path}", ${range.startLine}, ${range.endLine}]\n`,
// Using yaml.dump() with `forceQuotes: true` ensures that all special
// characters are escaped, and that the path is always rendered as a
// quoted string on a single line.
` - [${yaml.dump(range.path, { forceQuotes: true }).trim()}, ` +
`${range.startLine}, ${range.endLine}]\n`,
)
.join("");
if (!data) {
Expand Down

0 comments on commit 3548ff5

Please sign in to comment.