Skip to content

Commit 50eb98a

Browse files
committed
fix(server): keep project list rows intact when titles contain tabs or newlines
1 parent e4eba21 commit 50eb98a

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

‎apps/server/src/cli/project.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,13 @@ it.effect("adds, renames, and removes projects through the V2 project CLI domain
154154
yield* runCli(["project", "rename", workspaceRoot, "Beta", "--base-dir", baseDir]);
155155
assert.equal((yield* readProjects(baseDir)).projects[0]?.title, "Beta");
156156

157+
yield* runCli(["project", "rename", workspaceRoot, "Two\nline\ttitle", "--base-dir", baseDir]);
158+
yield* runCli(["project", "list", "--base-dir", baseDir]);
159+
assert.equal(
160+
(yield* TestConsole.logLines).at(-1),
161+
`${added?.id}\tTwo line title\t${workspaceRoot}`,
162+
);
163+
157164
yield* runCli(["project", "remove", added?.id ?? "", "--base-dir", baseDir]);
158165
assert.deepEqual((yield* readProjects(baseDir)).projects, []);
159166

‎apps/server/src/cli/project.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,12 @@ const projectListCommand = Command.make("list", projectLocationFlags).pipe(
588588
active.length === 0
589589
? "No projects."
590590
: active
591-
.map((project) => `${project.id}\t${project.title}\t${project.workspaceRoot}`)
591+
.map((project) =>
592+
// Titles and paths may contain tabs or newlines; keep one row of three columns.
593+
[project.id, project.title, project.workspaceRoot]
594+
.map((field) => field.replace(/[\t\r\n]/g, " "))
595+
.join("\t"),
596+
)
592597
.join("\n"),
593598
);
594599
}),

0 commit comments

Comments
 (0)