mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug 798679 - Unicode normalization should be used for comparison but not stored.
Change to NFC normalization for all comparisons because the Unicode meaning of compatible might collide with the user's intent.
This commit is contained in:
parent
797098c6e5
commit
b922cfd78d
@ -2828,7 +2828,7 @@ gboolean gnc_tree_view_search_compare (GtkTreeModel *model, gint column,
|
||||
gchar *case_normalized_key = NULL;
|
||||
gboolean match = FALSE;
|
||||
|
||||
normalized_key = g_utf8_normalize (key, -1, G_NORMALIZE_ALL);
|
||||
normalized_key = g_utf8_normalize (key, -1, G_NORMALIZE_NFC);
|
||||
if (normalized_key)
|
||||
case_normalized_key = g_utf8_casefold (normalized_key, -1);
|
||||
if (case_normalized_key)
|
||||
@ -2857,7 +2857,7 @@ gboolean gnc_tree_view_search_compare (GtkTreeModel *model, gint column,
|
||||
if (!str)
|
||||
continue;
|
||||
|
||||
normalized_string = g_utf8_normalize (str, -1, G_NORMALIZE_ALL);
|
||||
normalized_string = g_utf8_normalize (str, -1, G_NORMALIZE_NFC);
|
||||
if (normalized_string)
|
||||
case_normalized_string = g_utf8_casefold (normalized_string, -1);
|
||||
if (case_normalized_string&&NULL!=strstr(case_normalized_string,case_normalized_key))
|
||||
|
@ -870,8 +870,8 @@ maybe_append_string (const char* match_string, const char* imp_string)
|
||||
if (!(imp_string && *imp_string))
|
||||
return retval;
|
||||
|
||||
norm_match_string = g_utf8_normalize (match_string, -1, G_NORMALIZE_ALL);
|
||||
norm_imp_string = g_utf8_normalize (imp_string, -1, G_NORMALIZE_ALL);
|
||||
norm_match_string = g_utf8_normalize (match_string, -1, G_NORMALIZE_NFC);
|
||||
norm_imp_string = g_utf8_normalize (imp_string, -1, G_NORMALIZE_NFC);
|
||||
|
||||
if (g_utf8_strlen (norm_imp_string, -1) > g_utf8_strlen (norm_match_string, -1) ||
|
||||
!strstr (norm_match_string, norm_imp_string))
|
||||
|
@ -986,7 +986,7 @@ static void populate_list (gpointer key, gpointer value, GtkListStore *list)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
const char *original = key;
|
||||
char *normalized = g_utf8_normalize (original, -1, G_NORMALIZE_ALL);
|
||||
char *normalized = g_utf8_normalize (original, -1, G_NORMALIZE_NFC);
|
||||
char *normalized_folded = normalized ? g_utf8_casefold (normalized, -1) : NULL;
|
||||
gtk_list_store_append (list, &iter);
|
||||
gtk_list_store_set (list, &iter,
|
||||
|
@ -536,7 +536,7 @@ gnc_combo_cell_type_ahead_search (const gchar* newval,
|
||||
GRegex* regex0 = g_regex_new (escaped_sep, 0, 0, NULL);
|
||||
char* rep_str = g_regex_replace_literal (regex0, escaped_newval, -1, 0,
|
||||
newval_rep, 0, NULL);
|
||||
char* normal_rep_str = g_utf8_normalize (rep_str, -1, G_NORMALIZE_ALL);
|
||||
char* normal_rep_str = g_utf8_normalize (rep_str, -1, G_NORMALIZE_NFC);
|
||||
GRegex *regex = g_regex_new (normal_rep_str, G_REGEX_CASELESS, 0, NULL);
|
||||
|
||||
gboolean valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (full_store),
|
||||
@ -565,7 +565,7 @@ gnc_combo_cell_type_ahead_search (const gchar* newval,
|
||||
gchar* normalized_str_data = NULL;
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (full_store), &iter, 0,
|
||||
&str_data, -1);
|
||||
normalized_str_data = g_utf8_normalize (str_data, -1, G_NORMALIZE_ALL);
|
||||
normalized_str_data = g_utf8_normalize (str_data, -1, G_NORMALIZE_NFC);
|
||||
|
||||
if (g_regex_match (regex, normalized_str_data, 0, NULL))
|
||||
{
|
||||
|
@ -61,11 +61,11 @@ qof_utf8_substr_nocase (const gchar *haystack, const gchar *needle)
|
||||
|
||||
haystack_casefold = g_utf8_casefold (haystack, -1);
|
||||
haystack_normalized = g_utf8_normalize (haystack_casefold, -1,
|
||||
G_NORMALIZE_ALL);
|
||||
G_NORMALIZE_NFC);
|
||||
g_free (haystack_casefold);
|
||||
|
||||
needle_casefold = g_utf8_casefold (needle, -1);
|
||||
needle_normalized = g_utf8_normalize (needle_casefold, -1, G_NORMALIZE_ALL);
|
||||
needle_normalized = g_utf8_normalize (needle_casefold, -1, G_NORMALIZE_NFC);
|
||||
g_free (needle_casefold);
|
||||
|
||||
p = strstr (haystack_normalized, needle_normalized);
|
||||
|
Loading…
Reference in New Issue
Block a user