diff --git a/gramps/gen/lib/name.py b/gramps/gen/lib/name.py index 6a6d0791b..ec8e6379a 100644 --- a/gramps/gen/lib/name.py +++ b/gramps/gen/lib/name.py @@ -43,6 +43,9 @@ from .date import Date from ..const import GRAMPS_LOCALE as glocale _ = glocale.translation.gettext +# table for skipping illegal control chars +INVISIBLE = dict.fromkeys(list(range(32))) + #------------------------------------------------------------------------- # # Personal Name @@ -379,7 +382,7 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, CitationBase, NoteBase, The call name's exact definition is not predetermined, and may be locale specific. """ - self.call = val + self.call = val.translate(INVISIBLE).strip() def get_nick_name(self): """ @@ -397,7 +400,7 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, CitationBase, NoteBase, The nick name of the person, a not official name the person is known with. """ - self.nick = val + self.nick = val.translate(INVISIBLE).strip() def get_family_nick_name(self): """ @@ -415,7 +418,7 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, CitationBase, NoteBase, The family nick name of the family of the person, a not official name use to denote the entire family. """ - self.famnick = val + self.famnick = val.translate(INVISIBLE).strip() def set_type(self, the_type): """Set the type of the Name instance.""" @@ -427,7 +430,7 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, CitationBase, NoteBase, def set_first_name(self, name): """Set the given name for the Name instance.""" - self.first_name = name + self.first_name = name.translate(INVISIBLE).strip() def get_first_name(self): """Return the given name for the Name instance.""" @@ -435,7 +438,7 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, CitationBase, NoteBase, def set_suffix(self, name): """Set the suffix (such as Jr., III, etc.) for the Name instance.""" - self.suffix = name + self.suffix = name.translate(INVISIBLE).strip() def get_suffix(self): """Return the suffix for the Name instance.""" @@ -443,7 +446,7 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, CitationBase, NoteBase, def set_title(self, title): """Set the title (Dr., Reverand, Captain) for the Name instance.""" - self.title = title + self.title = title.translate(INVISIBLE).strip() def get_title(self): """Return the title for the Name instance.""" diff --git a/gramps/gen/lib/surname.py b/gramps/gen/lib/surname.py index ad45dff70..aa11cbfbf 100644 --- a/gramps/gen/lib/surname.py +++ b/gramps/gen/lib/surname.py @@ -35,6 +35,9 @@ from .const import IDENTICAL, EQUAL, DIFFERENT from ..const import GRAMPS_LOCALE as glocale _ = glocale.translation.gettext +# table for skipping illegal control chars +INVISIBLE = dict.fromkeys(list(range(32))) + #------------------------------------------------------------------------- # # Personal Name @@ -171,7 +174,7 @@ class Surname(SecondaryObject): The surname is one of the not given names coming from the parents """ - self.surname = val + self.surname = val.translate(INVISIBLE).strip() def get_prefix(self): """ @@ -187,7 +190,7 @@ class Surname(SecondaryObject): Examples of articles would be 'de' or 'van'. """ - self.prefix = val + self.prefix = val.translate(INVISIBLE).strip() def set_origintype(self, the_type): """Set the origin type of the Surname instance."""