IE <9 does not define String.prototype.trim, so we have to strip whitespace
manually.