Strip leading/trailing whitespace when parsing colors and other strings (bug #4937)