Be more lenient with trim()

Allowing for null and undefined values to return empty string.

I'm not sure if you would rather deal with this in the function calling trim() but this will at least allow some leeway when dealing with attributes that may be null or contain a string.