metalsmith / permalinks

A Metalsmith plugin for permalinks.
MIT License
62 stars 67 forks source link

Colon in pattern causes crash or hanged process #94

Closed SmashManiac closed 11 months ago

SmashManiac commented 5 years ago

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

Additional context The issue was introduced in v2.0.0.

webketje commented 2 years ago

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