gnucash stable: [engine.i] delegate gnc:html-string-sanitize to g_markup_escape_text

Christopher Lam clam at code.gnucash.org
Wed Sep 23 20:25:48 EDT 2026


Updated	 via  https://github.com/Gnucash/gnucash/commit/0cbce35a (commit)
	from  https://github.com/Gnucash/gnucash/commit/cb304edf (commit)



commit 0cbce35a474e2d234eaab940626c24846c12183a
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Thu Sep 24 08:24:41 2026 +0800

    [engine.i] delegate gnc:html-string-sanitize to g_markup_escape_text

diff --git a/bindings/engine.i b/bindings/engine.i
index 5a6d3e4b40..6610e6f651 100644
--- a/bindings/engine.i
+++ b/bindings/engine.i
@@ -63,6 +63,8 @@
 using SplitsVec = std::vector<Split*>;
 using AccountVec = std::vector<Account*>;
 
+gchar* gnc_html_string_sanitize (const char* str);
+
 SplitsVec gnc_get_match_commodity_splits (AccountVec accounts, bool use_end_date,
                                           time64 end_date, gnc_commodity *comm, bool sort);
 
@@ -154,6 +156,13 @@ static const GncGUID * gncPriceGetGUID(GNCPrice *x)
 static const GncGUID * gncBudgetGetGUID(GncBudget *x)
 { return qof_instance_get_guid(QOF_INSTANCE(x)); }
 
+
+gchar*
+gnc_html_string_sanitize (const char* str)
+{
+    return g_markup_escape_text (str, -1);
+}
+
 SplitsVec gnc_get_match_commodity_splits (AccountVec accounts, bool use_end_date,
                                           time64 end_date, gnc_commodity *comm, bool sort)
 {
diff --git a/bindings/guile/utilities.scm b/bindings/guile/utilities.scm
index e83b917ba2..5e3e54231e 100644
--- a/bindings/guile/utilities.scm
+++ b/bindings/guile/utilities.scm
@@ -112,18 +112,8 @@
 ;; function to sanitize strings. the resulting string can be safely
 ;; added to html.
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(define (gnc:html-string-sanitize str)
-  (with-output-to-string
-    (lambda ()
-      (string-for-each
-       (lambda (c)
-         (display
-          (case c
-            ((#\&) "&")
-            ((#\<) "<")
-            ((#\>) ">")
-            (else c))))
-       str))))
+(define gnc:html-string-sanitize
+  gnc-html-string-sanitize)
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; avoid using strftime, still broken in guile-2.2. see explanation at



Summary of changes:
 bindings/engine.i            |  9 +++++++++
 bindings/guile/utilities.scm | 14 ++------------
 2 files changed, 11 insertions(+), 12 deletions(-)



More information about the gnucash-changes mailing list