defaultFileName replaced unsafe characters before cutting the name short, so the cut could leave a device name: `CONSOLE.` before a 251-letter extension became `CON.` and that extension, and `NULL.` became `NUL.`. A name the cut leaves as a device name now gets a leading `_`, as sanitizeFileName gives one, and is cut a byte shorter to leave room for it. The backup's links and album folders and the `backup-metadata` album folders need no change: the ID comes right after or right before the part that is cut, so that part can never be a device name. Model: opus-5-5
This commit is contained in:
@@ -216,4 +216,13 @@ describe("defaultFileName", () => {
|
||||
`${"t".repeat(250)}.heic`,
|
||||
);
|
||||
});
|
||||
|
||||
// Cutting `CONSOLE` or `NULL` short before a long extension leaves `CON`
|
||||
// or `NUL`, so the name gets the `_` `sanitizeFileName` gives a device
|
||||
// name, and the part before the extension gives up a byte for it.
|
||||
it("never returns a Windows device name, even once cut short", () => {
|
||||
const ext = `.${"e".repeat(251)}`;
|
||||
expect(defaultFileName(`CONSOLE${ext}`, 42)).toBe(`_CO${ext}`);
|
||||
expect(defaultFileName(`NULL${ext}`, 42)).toBe(`_NU${ext}`);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user