[gnumeric] ods: fix import problem with crazy named expressions.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] ods: fix import problem with crazy named expressions.
- Date: Wed, 6 Jan 2021 00:37:10 +0000 (UTC)
commit 587388f935d35ab57a25aa55200da587a33ed1e9
Author: Morten Welinder <terra gnome org>
Date: Tue Jan 5 19:36:34 2021 -0500
ods: fix import problem with crazy named expressions.
"19" as a name was throwing us off.
NEWS | 1 +
plugins/openoffice/openoffice-read.c | 14 ++++++++++++++
2 files changed, 15 insertions(+)
---
diff --git a/NEWS b/NEWS
index 85f61ae32..4416f93be 100644
--- a/NEWS
+++ b/NEWS
@@ -20,6 +20,7 @@ Morten:
* Fix ssconvert sheet selection for csv. [#555]
* Test suite improvements.
* Fix ods import problem with irregular sheet sizes.
+ * Fix ods import problem with crazy named expressions. [#557]
--------------------------------------------------------------------------
Gnumeric 1.12.48
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index b30fb9027..3a4af531a 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -2074,8 +2074,22 @@ odf_fix_en_collect (G_GNUC_UNUSED gconstpointer key_,
here[i] = '_';
}
}
+
+ // If the name is inherently invalid ("19" as in #557) then mangle
+ // it first.
+ if (!expr_name_validate (str->str)) {
+ g_string_insert (str, 0, "NAME");
+ if (!expr_name_validate (str->str)) {
+ char *p;
+ for (p = str->str; *p; p++)
+ if (!g_ascii_isalnum (*p))
+ *p = 'X';
+ }
+ }
+
while (!odf_fix_en_validate (str->str, fen))
g_string_append_c (str, '_');
+
odf_fix_expr_names_t_add (fen, name, g_string_free (str, FALSE));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]