encodeURIComponent on dirname

Fixes https://github.com/owncloud/documents/issues/406