rogerc / file-stream-rotator

NodeJS file stream rotator
MIT License
143 stars 69 forks source link

Fix handling special characters in filename path #94

Closed lukaszjenczmyk closed 1 year ago

lukaszjenczmyk commented 2 years ago

Hey, I noticed a bug related to handling paths with special characters (for example special-characters-test-logs))/program.log):

regex-error

It matters a lot when the code is executed on clients' machines (for example in Electron applications) because the paths can't be trusted and need to be sanitized before creating a regex.

I included a test that shows what used to fail. I don't know why the testGetStream function in test.js starts with return statement (which effectively disables that part of tests), but once you remove the return statement, the tests work fine.

rogerc commented 2 years ago

Hi @lukaszjenczmyk

Thanks for this pull request. I've rewritten the library using Typescript. The new way doesn't do a match against log file, just the extension and that is being escaped to be safe. Link to v1 below. I hope to release it in 7 days or so.

https://github.com/rogerc/file-stream-rotator/tree/v1

lukaszjenczmyk commented 1 year ago

Thanks @rogerc. In that case, I'm closing this pull request.