From 6ba958cc413ca476b3b1ca340fb034e49de10706 Mon Sep 17 00:00:00 2001 From: SNoiraud Date: Fri, 30 Aug 2019 08:56:25 +0200 Subject: [PATCH] Avoid all characters looking like a dash hyphen non breaking hyphen figure dash em dash horizontal bar Fixes #11308 --- gramps/plugins/tool/removespaces.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/gramps/plugins/tool/removespaces.py b/gramps/plugins/tool/removespaces.py index 952a94fe0..1c2c4d025 100644 --- a/gramps/plugins/tool/removespaces.py +++ b/gramps/plugins/tool/removespaces.py @@ -53,6 +53,22 @@ _ = glocale.translation.sgettext WIKI_HELP_PAGE = '%s_-_Tools' % URL_MANUAL_PAGE WIKI_HELP_SEC = _('manual|Remove_leading_and_trailing_spaces') +def validate_lat_lon(field): + """ + Return True if some characters are found in the field + # hyphen (u+2010) + # non-breaking hyphen (u+2011) + # figure dash (u+2012) + # en dash (u+2013) + # em dash (u+2014) + # horizontal bar (u+2015) + """ + for char in (',', '\u2010', '\u2011', '\u2012', + '\u2013', '\u2014', '\u2015'): + if field.find(char) != -1: + return True + return False + #------------------------------------------------------------------------ # # RemoveSpaces class @@ -214,12 +230,12 @@ class RemoveSpaces(ManagedWindow): plat = place.get_latitude() if plat != plat.strip(): found = True - if plat.find(',') != -1: + if validate_lat_lon(plat): found = True plon = place.get_longitude() if plon != plon.strip(): found = True - if plon.find(',') != -1: + if validate_lat_lon(plon): found = True if found: value = (place_handle, pname, plat, plon)