function isSafe(userAgent) {
  var consecutive = 0
    , code = 0;

  if (userAgent.length > 1000) return false;

  for (var i = 0; i < userAgent.length; i++) {
    code = userAgent.charCodeAt(i);
    if ((code >= 48 && code <= 57) || // numbers
        (code >= 65 && code <= 90) || // letters A-Z
        (code >= 97 && code <= 122) || // letters a-z
        code <= 32 // spaces and control
      ) {
      consecutive++;
    } else {
      consecutive = 0;
    }

    if (consecutive >= 100) {
      return false;
    }
  }

  return true
}
Check if the userAgent is something we want to parse with regexp's.

@param {String} userAgent The userAgent.
@returns {Boolean}