permalinks icon indicating copy to clipboard operation
permalinks copied to clipboard

Colon in pattern causes crash or hanged process

Open SmashManiac opened this issue 5 years ago • 1 comments

Describe the bug When a colon appears in the metadata referenced by the pattern property, it causes Metalsmith to crash at best, or hang indefinitely at worse, depending on the length of the processed metadata.

Crash message example:

EINVAL: invalid argument, mkdir 'C:\permalinks-bug\build\:'] {
  errno: ←[33m-4071←[39m,
  code: ←[32m'EINVAL'←[39m,
  syscall: ←[32m'mkdir'←[39m,
  path: ←[32m'C:\\permalinks-bug\\build\\:'←[39m
}

To Reproduce Steps to reproduce the behavior:

  1. Extract permalinks-bug.zip
  2. Run npm install
  3. Run node index

Expected behavior Special characters in the permalink pattern metadata should be gracefully processed.

Environment

  • Windows 7 SP1
  • Node.js 12.9.0 (includes npm 6.10.2)
  • NTFS file system

Additional context The issue was introduced in v2.0.0.

SmashManiac avatar Aug 25 '19 01:08 SmashManiac

Whether colon is a valid dir char depends on the OS. In Linux, colons are valid directory chars. It seems highly unlikely that anyone would want a colon in their destination path, especially in the case of a static site. Therefore the most straightforward solution would be to strip it

webketje avatar Dec 19 '21 00:12 webketje