Fix issue #669 - stripping of octets breaks our %%variables%%

Also fixed potential similar issue with url validation and created helper function for this