metalsmith / permalinks

A Metalsmith plugin for permalinks.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Colon in pattern causes crash or hanged process

SmashManiac opened this issue · 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.

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