mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-10 02:15:02 +00:00
* fix(diff): decode quoted Git patch paths * fix(server): preserve Git paths in diff and commit listings * refactor(diff): make quoted-path conversions explicit * test(server): verify quoted filename diffs through daemon RPC Keep the checkout and commit-file regression on the public client interface, and align the large-file command assertion with NUL-delimited statistics. Co-authored-by: 见安 <73627805+Mar-garet@users.noreply.github.com> * test(server): run filename RPC regression in integration checks --------- Co-authored-by: 见安 <73627805+Mar-garet@users.noreply.github.com> Co-authored-by: paseo-bot[bot] <266920839+paseo-bot[bot]@users.noreply.github.com>
35 lines
954 B
TypeScript
35 lines
954 B
TypeScript
const GIT_PATH_ESCAPE_BYTES: Record<string, number> = {
|
|
a: 7,
|
|
b: 8,
|
|
t: 9,
|
|
n: 10,
|
|
v: 11,
|
|
f: 12,
|
|
r: 13,
|
|
'"': 34,
|
|
"\\": 92,
|
|
};
|
|
|
|
// core.quotepath=false still quotes control characters, double quotes and backslashes.
|
|
export function unquoteGitPath(value: string): string {
|
|
if (!value.startsWith('"') || !value.endsWith('"')) return value;
|
|
|
|
const encoded = value.slice(1, -1);
|
|
const parts: Buffer[] = [];
|
|
let offset = 0;
|
|
for (const match of encoded.matchAll(/\\([0-7]{1,3}|[abfnrtv"\\])/g)) {
|
|
parts.push(Buffer.from(encoded.slice(offset, match.index)));
|
|
const escape = match[1];
|
|
let byte: number;
|
|
if (/^[0-7]/.test(escape)) {
|
|
byte = Number.parseInt(escape, 8);
|
|
} else {
|
|
byte = GIT_PATH_ESCAPE_BYTES[escape];
|
|
}
|
|
parts.push(Buffer.from([byte]));
|
|
offset = match.index + match[0].length;
|
|
}
|
|
parts.push(Buffer.from(encoded.slice(offset)));
|
|
return Buffer.concat(parts).toString("utf8");
|
|
}
|