gnucash maint: Multiple changes pushed
Christopher Lam
clam at code.gnucash.org
Thu Dec 30 00:32:54 EST 2021
Updated via https://github.com/Gnucash/gnucash/commit/6dcb73db (commit)
via https://github.com/Gnucash/gnucash/commit/bf56026e (commit)
via https://github.com/Gnucash/gnucash/commit/ff75ad70 (commit)
via https://github.com/Gnucash/gnucash/commit/b57f9004 (commit)
via https://github.com/Gnucash/gnucash/commit/b435ee60 (commit)
from https://github.com/Gnucash/gnucash/commit/61d273f7 (commit)
commit 6dcb73db9e92758dd36e7acb6b2326743893ca7e
Merge: 61d273f7b bf56026e9
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Thu Dec 30 13:14:02 2021 +0800
Merge branch '798392' into maint #1222
commit bf56026e93403e4e21d90ccf5310eb1642233ac3
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Thu Dec 30 13:04:36 2021 +0800
html-utilities: don't need (sxml simple) module
it was used for a sxml->xml transform. this would create a void script
tag <script ... /> which is valid xml but is not valid html.
diff --git a/gnucash/report/html-utilities.scm b/gnucash/report/html-utilities.scm
index 033723ada..9912c5f4e 100644
--- a/gnucash/report/html-utilities.scm
+++ b/gnucash/report/html-utilities.scm
@@ -35,7 +35,6 @@
(use-modules (gnucash report html-text))
(use-modules (gnucash report html-table))
(use-modules (ice-9 match))
-(use-modules (sxml simple))
(use-modules (web uri))
(export gnc:html-make-empty-cell)
commit ff75ad7043fc6e3d6c216b93a698a2d05522a358
Author: John Ralls <jralls at ceridwen.us>
Date: Mon Dec 27 09:44:00 2021 -0800
gnc:html-foo-include: Use gnc-resolve-file-path.
diff --git a/bindings/core-utils.i b/bindings/core-utils.i
index e5cd3cf54..f8c9edb3c 100644
--- a/bindings/core-utils.i
+++ b/bindings/core-utils.i
@@ -69,15 +69,15 @@ gchar * gnc_path_get_localedir(void);
%newobject gnc_path_get_stdreportsdir;
gchar * gnc_path_get_stdreportsdir(void);
-%newobject gnc_path_find_localized_html_file;
-gchar * gnc_path_find_localized_html_file(const gchar *);
-
%newobject gnc_build_userdata_path;
gchar * gnc_build_userdata_path(const gchar *);
%newobject gnc_file_path_absolute;
gchar *gnc_file_path_absolute (const gchar *, const gchar *);
+%newobject gnc_resolve_file_path;
+gchar *gnc_resolve_file_path (const gchar *);
+
%newobject gnc_build_scm_path;
gchar * gnc_build_scm_path(const gchar *);
diff --git a/gnucash/report/html-chart.scm b/gnucash/report/html-chart.scm
index 6750c51ed..1091a89fe 100644
--- a/gnucash/report/html-chart.scm
+++ b/gnucash/report/html-chart.scm
@@ -444,8 +444,7 @@ document.getElementById(chartid).onclick = function(evt) {
;; clashing on multi-column reports
(id (symbol->string (gensym "chart"))))
- (push (gnc:html-js-include
- (gnc-path-find-localized-html-file "chartjs/Chart.bundle.min.js")))
+ (push (gnc:html-js-include "chartjs/Chart.bundle.min.js"))
;; the following hidden h3 is used to query style and copy onto chartjs
(push "<h3 style='display:none'></h3>")
diff --git a/gnucash/report/html-utilities.scm b/gnucash/report/html-utilities.scm
index 20bf5e354..033723ada 100644
--- a/gnucash/report/html-utilities.scm
+++ b/gnucash/report/html-utilities.scm
@@ -425,12 +425,12 @@
(define (gnc:html-js-include file)
(format #f
"<script language=\"javascript\" type=\"text/javascript\" src=~s></script>\n"
- (make-uri (gnc-path-find-localized-html-file file))))
+ (make-uri (gnc-resolve-file-path file))))
(define (gnc:html-css-include file)
(format #f
- "<link rel=\"stylesheet\" type=\"text/css\" href=\"file:///~a\" />\n"
- (gnc-path-find-localized-html-file file)))
+ "<link rel=\"stylesheet\" type=\"text/css\" href=~s />\n"
+ (make-uri (gnc-resolve-file-path file))))
commit b57f900401fab51665d98048810a962ccc7ba754
Author: John Ralls <jralls at ceridwen.us>
Date: Mon Dec 27 09:43:09 2021 -0800
make-uri: Ensure correct number of slashes in file URI.
diff --git a/gnucash/report/html-utilities.scm b/gnucash/report/html-utilities.scm
index 7fc0666e2..20bf5e354 100644
--- a/gnucash/report/html-utilities.scm
+++ b/gnucash/report/html-utilities.scm
@@ -413,11 +413,14 @@
(string->char-set ":/?#[]@") ;gen-delims
(string->char-set "-._~")))
+;;path must be absolute. On Windows an absolute path begins with a
+;;drive letter followed by a colon.
(define (make-uri path)
- (string-append
- "file://"
- (uri-encode (gnc:substring-replace path "\\" "/")
+ (let ((uri-path (uri-encode (gnc:substring-replace path "\\" "/")
#:unescaped-chars unreserved-chars-rfc3986)))
+ (string-append
+ (if (char=? (string-ref uri-path 0) #\/) "file://" "file:///")
+ uri-path)))
(define (gnc:html-js-include file)
(format #f
diff --git a/gnucash/report/test/test-html-utilities-srfi64.scm b/gnucash/report/test/test-html-utilities-srfi64.scm
index 14e1104b8..436286472 100644
--- a/gnucash/report/test/test-html-utilities-srfi64.scm
+++ b/gnucash/report/test/test-html-utilities-srfi64.scm
@@ -25,7 +25,7 @@
(test-begin "test-html-includes")
(test-equal "windows path into rfc3986 uri"
- "file://C:/Program%20Files%20%28x86%29/gnucash/share/gnucash/chartjs/Chart.bundle.min.js"
+ "file:///C:/Program%20Files%20%28x86%29/gnucash/share/gnucash/chartjs/Chart.bundle.min.js"
(make-uri "C:\\Program Files (x86)\\gnucash/share\\gnucash\\chartjs/Chart.bundle.min.js"))
(test-end "test-html-includes"))
commit b435ee60c0b1254003954b60ad8c71beb49fe423
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Tue Dec 21 17:46:37 2021 +0800
Bug 798392 - Reports do not display when Reports JavaScript
dependencies are located at a filepath that includes special characters like hash ("#")
using a sanitizing function using homegrown charset from guile's uri.scm
diff --git a/gnucash/report/html-utilities.scm b/gnucash/report/html-utilities.scm
index dcb45ca10..7fc0666e2 100644
--- a/gnucash/report/html-utilities.scm
+++ b/gnucash/report/html-utilities.scm
@@ -35,6 +35,8 @@
(use-modules (gnucash report html-text))
(use-modules (gnucash report html-table))
(use-modules (ice-9 match))
+(use-modules (sxml simple))
+(use-modules (web uri))
(export gnc:html-make-empty-cell)
(export gnc:html-make-empty-cells)
@@ -405,10 +407,22 @@
(G_ "No data")
(G_ "The selected accounts contain no data/transactions (or only zeroes) for the selected time period")))
+(define unreserved-chars-rfc3986
+ (char-set-union
+ (string->char-set "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
+ (string->char-set ":/?#[]@") ;gen-delims
+ (string->char-set "-._~")))
+
+(define (make-uri path)
+ (string-append
+ "file://"
+ (uri-encode (gnc:substring-replace path "\\" "/")
+ #:unescaped-chars unreserved-chars-rfc3986)))
+
(define (gnc:html-js-include file)
(format #f
- "<script language=\"javascript\" type=\"text/javascript\" src=\"file:///~a\"></script>\n"
- (gnc-path-find-localized-html-file file)))
+ "<script language=\"javascript\" type=\"text/javascript\" src=~s></script>\n"
+ (make-uri (gnc-path-find-localized-html-file file))))
(define (gnc:html-css-include file)
(format #f
diff --git a/gnucash/report/test/test-html-utilities-srfi64.scm b/gnucash/report/test/test-html-utilities-srfi64.scm
index f724054df..14e1104b8 100644
--- a/gnucash/report/test/test-html-utilities-srfi64.scm
+++ b/gnucash/report/test/test-html-utilities-srfi64.scm
@@ -1,5 +1,5 @@
(use-modules (gnucash app-utils))
-(use-modules (gnucash report))
+(use-modules (gnucash report html-utilities))
(use-modules (tests test-engine-extras))
(use-modules (tests test-report-extras))
(use-modules (tests srfi64-extras))
@@ -9,8 +9,11 @@
(test-runner-factory gnc:test-runner)
(test-begin "test-html-utilities-srfi64.scm")
(test-gnc:assign-colors)
+ (test-html-includes)
(test-end "test-html-utilities-srfi64.scm"))
+(define make-uri (@@ (gnucash report html-utilities) make-uri))
+
(define (test-gnc:assign-colors)
(test-begin "test-gnc:assign-colors")
(test-equal "assign-colors can request many colors"
@@ -18,3 +21,11 @@
(length (gnc:assign-colors 99)))
(test-end "test-gnc:assign-colors"))
+(define (test-html-includes)
+ (test-begin "test-html-includes")
+
+ (test-equal "windows path into rfc3986 uri"
+ "file://C:/Program%20Files%20%28x86%29/gnucash/share/gnucash/chartjs/Chart.bundle.min.js"
+ (make-uri "C:\\Program Files (x86)\\gnucash/share\\gnucash\\chartjs/Chart.bundle.min.js"))
+
+ (test-end "test-html-includes"))
Summary of changes:
bindings/core-utils.i | 6 +++---
gnucash/report/html-chart.scm | 3 +--
gnucash/report/html-utilities.scm | 24 ++++++++++++++++++----
gnucash/report/test/test-html-utilities-srfi64.scm | 13 +++++++++++-
4 files changed, 36 insertions(+), 10 deletions(-)
More information about the gnucash-changes
mailing list