This isn't directly related to your patch,  but if `value` isn't a string then there's no reason to do the `.test()`. So ignore my other suggestion and I recommend doing this above the initial `if()`:
```javascript
if (typeof value !== 'string' || value.length == 0) {
  if (value != null)
    value = '' + value;
  if (value.length > 0)
    state.messageHeader += field + ': ' + value + CRLF;
}
```
Or at least something to that effect. I haven't tested this code, but the fact that we're allowing regex checks to be performed on non strings before explicitly converting them to strings is incorrect.