Trim off whitespace when saving custom fields

3.0-unstable patch of #2386
Merge pull request #2427 from jamesgol/trimcustom-3

Trim off whitespace when saving custom fields