[stable6] backport share key pattern matching fix

Backport of
- webdav copy fix with encryption: https://github.com/owncloud/core/pull/9897 (required prerequisite)
- fix share key with encryption: https://github.com/owncloud/core/pull/11137

Fixes https://github.com/owncloud/core/issues/11252

@schiesbn the backport of #11137 applies with no major conflicts thanks to the backport of #9897.

- [x] Needs extensive testing
- [x] Double check that there are no remaining bogus preg_match or glob calls