Verify whether the URL is valid

Required for https://github.com/owncloud/mail/pull/100#issuecomment-50266017

@karlitschek Backport for stable6 and stable7 requested.
Merge pull request #9935 from owncloud/harden-get-urlco

Verify whether the URL is valid