The check for invalid paths is actually over-complicated and performed twice resulting in a performance penalty. Additionally, I decided to add unit-tests to that function. Part of https://github.com/owncloud/core/issues/13221