[stable5] Backport: Fixed various file name escaping issues in core apps

Backport of https://github.com/owncloud/core/pull/6713 to stable5
It had a few conflicts

Please review/test @LukasReschke @karlitschek @DeepDiver1975 @schiesbn