def email_address(self, value): # Silently truncate if necessary. In practice, this may be too # long if somebody put a super-long email into their contacts by # mistake or something. if value is not None: value = unicode_safe_truncate(value, MAX_INDEXABLE_LENGTH) self._raw_address = value self._canonicalized_address = canonicalize_address(value)
def sanitize_subject(self, key, value): # Trim overlong subjects, and remove null bytes. The latter can result # when, for example, UTF-8 text decoded from an RFC2047-encoded header # contains null bytes. if value is None: return value = unicode_safe_truncate(value, 255) value = value.replace('\0', '') return value
def sanitize_name(name): return unicode_safe_truncate(name, MAX_INDEXABLE_LENGTH)
def calculate_plaintext_snippet(self, text): return unicode_safe_truncate(' '.join(text.split()), SNIPPET_LENGTH)
def validate_master_event_uid_length(self, key, value): if value is None: return None return unicode_safe_truncate(value, MAX_LENS[key])
def validate_text_column_length(self, key, value): if value is None: return None return unicode_safe_truncate(value, MAX_TEXT_CHARS)
def validate_length(self, key, value): if value is None: return None return unicode_safe_truncate(value, MAX_TEXT_LENGTH)