gnucash maint: Multiple changes pushed
Geert Janssens
gjanssens at code.gnucash.org
Fri Apr 27 13:14:54 EDT 2018
Updated via https://github.com/Gnucash/gnucash/commit/3e41bb01 (commit)
via https://github.com/Gnucash/gnucash/commit/ecab5803 (commit)
via https://github.com/Gnucash/gnucash/commit/583c0217 (commit)
via https://github.com/Gnucash/gnucash/commit/ba2c1f6a (commit)
via https://github.com/Gnucash/gnucash/commit/fcb5f64b (commit)
via https://github.com/Gnucash/gnucash/commit/ea71c696 (commit)
from https://github.com/Gnucash/gnucash/commit/bc5f86ff (commit)
commit 3e41bb011d672c811d2a533f56bf2fbb44b4dec2
Merge: bc5f86f ecab580
Author: Geert Janssens <geert at kobaltwit.be>
Date: Fri Apr 27 19:06:23 2018 +0200
Merge branch 'maint-string-html-escape' of https://github.com/christopherlam/gnucash into maint
commit ecab5803519d2dd2972e8f825f52c39a53b6216b
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Apr 28 00:37:27 2018 +0800
Remove regex dependency
diff --git a/gnucash/report/standard-reports/account-piecharts.scm b/gnucash/report/standard-reports/account-piecharts.scm
index 0277dc9..c00c62d 100644
--- a/gnucash/report/standard-reports/account-piecharts.scm
+++ b/gnucash/report/standard-reports/account-piecharts.scm
@@ -27,7 +27,6 @@
(use-modules (gnucash utilities))
(use-modules (srfi srfi-1))
-(use-modules (ice-9 regex))
(use-modules (gnucash gnc-module))
(use-modules (gnucash gettext))
diff --git a/gnucash/report/standard-reports/budget-barchart.scm b/gnucash/report/standard-reports/budget-barchart.scm
index 24fc3ad..4bb7ed4 100644
--- a/gnucash/report/standard-reports/budget-barchart.scm
+++ b/gnucash/report/standard-reports/budget-barchart.scm
@@ -33,9 +33,6 @@
(gnc:module-load "gnucash/report/report-system" 0)
-;; included since Bug726449
-(use-modules (ice-9 regex)) ;; for regexp-substitute/global, used by jpqplot
-
(define reportname
(N_ "Budget Chart"))
diff --git a/gnucash/report/standard-reports/daily-reports.scm b/gnucash/report/standard-reports/daily-reports.scm
index 5339ff2..8b0309a 100644
--- a/gnucash/report/standard-reports/daily-reports.scm
+++ b/gnucash/report/standard-reports/daily-reports.scm
@@ -30,7 +30,6 @@
(use-modules (gnucash utilities))
(use-modules (srfi srfi-1))
-(use-modules (ice-9 regex))
(use-modules (gnucash gnc-module))
(use-modules (gnucash gettext))
diff --git a/gnucash/report/standard-reports/net-barchart.scm b/gnucash/report/standard-reports/net-barchart.scm
index 7479dbc..dc3e5c2 100644
--- a/gnucash/report/standard-reports/net-barchart.scm
+++ b/gnucash/report/standard-reports/net-barchart.scm
@@ -37,9 +37,6 @@
(gnc:module-load "gnucash/report/report-system" 0)
-;; included since Bug726449
-(use-modules (ice-9 regex)) ;; for regexp-substitute/global, used by jpqplot
-
(define reportname (N_ "Income/Expense Chart"))
(define optname-from-date (N_ "Start Date"))
commit 583c0217c49b253064edd487d738fc8cc92f0792
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Apr 28 00:35:53 2018 +0800
line&bar chart subtitles are always sanitized
This obviates bug 726449 for consistency
diff --git a/gnucash/report/report-system/html-barchart.scm b/gnucash/report/report-system/html-barchart.scm
index 37f2c86..8b3f847 100644
--- a/gnucash/report/report-system/html-barchart.scm
+++ b/gnucash/report/report-system/html-barchart.scm
@@ -135,24 +135,6 @@
(define gnc:html-barchart-subtitle
(record-accessor <html-barchart> 'subtitle))
-;; Note: Due to Bug726449 the input string's non-printable control
-;; characters must translated to HTML format tags BEFORE
-;; or WHEN calling this function.
-;; AND:
-;; To ensure that the generated subtitle doesn't contain any
-;; unescaped quotes or backslashes, all strings must be freed
-;; from those by calling gnc:html-string-sanitize.
-;; Otherwise we're opening the gates again for bug 721768.
-;;
-;; Example: "\n" must be translated to "<br /> to introduce
-;; a line break into the chart subtitle.
-;;
-;; Example call:
-;; (gnc:html-barchart-set-subtitle! chart
-;; (string-append "Bgt:"
-;; (gnc:html-string-sanitize (number->string bgt-sum))
-;; "<br /> Act:" ;; line break in the chart sub-title
-;; (gnc:html-string-sanitize (number->string act-sum))))
(define gnc:html-barchart-set-subtitle!
(record-modifier <html-barchart> 'subtitle))
diff --git a/gnucash/report/report-system/html-scatter.scm b/gnucash/report/report-system/html-scatter.scm
index f2d1ad6..67647b3 100644
--- a/gnucash/report/report-system/html-scatter.scm
+++ b/gnucash/report/report-system/html-scatter.scm
@@ -205,14 +205,12 @@
};\n")
(if title
- (begin
- (push " options.title = \"")
- (push title) (push "\";\n")))
+ (push (format #f " options.title = ~s;\n"
+ (gnc:html-string-sanitize title))))
(if subtitle
- (begin
- (push " options.title += \" (")
- (push subtitle) (push ")\";\n")))
+ (push (format #f " options.title += ' (' + ~s + ')';\n"
+ (gnc:html-string-sanitize subtitle))))
(if (and (string? x-label) (> (string-length x-label) 0))
(begin
diff --git a/gnucash/report/standard-reports/budget-barchart.scm b/gnucash/report/standard-reports/budget-barchart.scm
index 1fadbc8..24fc3ad 100644
--- a/gnucash/report/standard-reports/budget-barchart.scm
+++ b/gnucash/report/standard-reports/budget-barchart.scm
@@ -237,14 +237,8 @@
(gnc:html-barchart-append-column! chart act-vals)
(gnc:html-barchart-set-row-labels! chart date-iso-string-list)
(if running-sum
- (gnc:html-barchart-set-subtitle! chart
- (string-append "Bgt:"
- (gnc:html-string-sanitize (number->string bgt-sum))
- "<br /> Act:"
- (gnc:html-string-sanitize (number->string act-sum))
- )
- )
- )
+ (gnc:html-barchart-set-subtitle!
+ chart (format #f "Bgt: ~a Act: ~a" bgt-sum act-sum)))
)
;; else
(begin
@@ -253,14 +247,9 @@
(gnc:html-linechart-append-column! chart act-vals)
(gnc:html-linechart-set-row-labels! chart date-iso-string-list)
(if running-sum
- (gnc:html-linechart-set-subtitle! chart
- (string-append "Bgt:"
- (gnc:html-string-sanitize (number->string bgt-sum))
- "<br /> Act:"
- (gnc:html-string-sanitize (number->string act-sum))
- )
- )
- )
+ (gnc:html-linechart-set-subtitle!
+ chart
+ (format #f "Bgt: ~a Act: ~a" bgt-sum act-sum)))
)
)
)
commit ba2c1f6a05cc05ecebc6cade060bcb46dd1e3166
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Fri Apr 27 21:51:13 2018 +0800
html-jqplot.scm begone!
Remove unused jqplot-escape-string, and move remaining
(gnc:html-[js|css]-include) functions to html-utilities.scm
diff --git a/gnucash/report/report-system/CMakeLists.txt b/gnucash/report/report-system/CMakeLists.txt
index bd21e6b..a511bf9 100644
--- a/gnucash/report/report-system/CMakeLists.txt
+++ b/gnucash/report/report-system/CMakeLists.txt
@@ -73,7 +73,6 @@ SET (report_system_SCHEME_3
html-table.scm
html-text.scm
html-utilities.scm
- html-jqplot.scm
options-utilities.scm
report-utilities.scm
report.scm
diff --git a/gnucash/report/report-system/html-barchart.scm b/gnucash/report/report-system/html-barchart.scm
index b6a04ad..37f2c86 100644
--- a/gnucash/report/report-system/html-barchart.scm
+++ b/gnucash/report/report-system/html-barchart.scm
@@ -21,7 +21,7 @@
;; Boston, MA 02110-1301, USA gnu at gnu.org
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(load-from-path "html-jqplot")
+(use-modules (gnucash report report-system))
(define <html-barchart>
(make-record-type "<html-barchart>"
diff --git a/gnucash/report/report-system/html-jqplot.scm b/gnucash/report/report-system/html-jqplot.scm
deleted file mode 100644
index 6325e08..0000000
--- a/gnucash/report/report-system/html-jqplot.scm
+++ /dev/null
@@ -1,44 +0,0 @@
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; This program is free software; you can redistribute it and/or
-;; modify it under the terms of the GNU General Public License as
-;; published by the Free Software Foundation; either version 2 of
-;; the License, or (at your option) any later version.
-;;
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;; GNU General Public License for more details.
-;;
-;; You should have received a copy of the GNU General Public License
-;; along with this program; if not, contact:
-;;
-;; Free Software Foundation Voice: +1-617-542-5942
-;; 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
-;; Boston, MA 02110-1301, USA gnu at gnu.org
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(use-modules (gnucash core-utils))
-
-(define (gnc:html-js-include file)
- (string-append
- "<script language=\"javascript\" type=\"text/javascript\" src=\"file:///"
- (gnc-path-find-localized-html-file file)
- "\"></script>\n"
- ))
-
-(define (gnc:html-css-include file)
- (string-append
- "<link rel=\"stylesheet\" type=\"text/css\" href=\"file:///"
- (gnc-path-find-localized-html-file file)
- "\" />\n"
- ))
-
-(define (jqplot-escape-string s1)
- ;; Escape single and double quotes and backslashes
- (set! s1 (regexp-substitute/global #f "\\\\" s1 'pre "\\\\" 'post))
- (set! s1 (regexp-substitute/global #f "'" s1 'pre "\\'" 'post))
- (set! s1 (regexp-substitute/global #f "\"" s1 'pre "\\\"" 'post))
- ;; Escape HTML special characters
- (set! s1 (regexp-substitute/global #f "&" s1 'pre "&" 'post))
- (set! s1 (regexp-substitute/global #f "<" s1 'pre "<" 'post))
- (regexp-substitute/global #f ">" s1 'pre ">" 'post))
diff --git a/gnucash/report/report-system/html-linechart.scm b/gnucash/report/report-system/html-linechart.scm
index 44ebd40..b9778a6 100644
--- a/gnucash/report/report-system/html-linechart.scm
+++ b/gnucash/report/report-system/html-linechart.scm
@@ -24,6 +24,8 @@
;; Boston, MA 02110-1301, USA gnu at gnu.org
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(use-modules (gnucash report report-system))
+
(define <html-linechart>
(make-record-type "<html-linechart>"
'(width
diff --git a/gnucash/report/report-system/html-piechart.scm b/gnucash/report/report-system/html-piechart.scm
index b93e526..de705f5 100644
--- a/gnucash/report/report-system/html-piechart.scm
+++ b/gnucash/report/report-system/html-piechart.scm
@@ -21,7 +21,7 @@
;; Boston, MA 02110-1301, USA gnu at gnu.org
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(load-from-path "html-jqplot")
+(use-modules (gnucash report report-system))
(define <html-piechart>
(make-record-type "<html-piechart>"
diff --git a/gnucash/report/report-system/html-scatter.scm b/gnucash/report/report-system/html-scatter.scm
index 3134208..f2d1ad6 100644
--- a/gnucash/report/report-system/html-scatter.scm
+++ b/gnucash/report/report-system/html-scatter.scm
@@ -24,7 +24,7 @@
;; Boston, MA 02110-1301, USA gnu at gnu.org
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(load-from-path "html-jqplot")
+(use-modules (gnucash report report-system))
(define <html-scatter>
(make-record-type "<html-scatter>"
diff --git a/gnucash/report/report-system/html-utilities.scm b/gnucash/report/report-system/html-utilities.scm
index feb8332..637cfe0 100644
--- a/gnucash/report/report-system/html-utilities.scm
+++ b/gnucash/report/report-system/html-utilities.scm
@@ -854,6 +854,16 @@
(_ "No data")
(_ "The selected accounts contain no data/transactions (or only zeroes) for the selected time period")))
+(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)))
+
+(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)))
+
;; function to sanitize strings prior to sending to html
(define (gnc:html-string-sanitize str)
(with-output-to-string
diff --git a/gnucash/report/report-system/report-system.scm b/gnucash/report/report-system/report-system.scm
index bf4d036..d305d54 100644
--- a/gnucash/report/report-system/report-system.scm
+++ b/gnucash/report/report-system/report-system.scm
@@ -119,6 +119,8 @@
(export gnc:html-make-generic-simple-warning)
(export gnc:html-make-empty-data-warning)
(export gnc:html-make-options-link)
+(export gnc:html-js-include)
+(export gnc:html-css-include)
(export gnc:html-string-sanitize)
;; report.scm
commit fcb5f64bd5b5d178ddefa12445bb6f5469bde76a
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Fri Apr 27 16:04:48 2018 +0800
jqplot-escape-string -> gnc:html-string-sanitize
diff --git a/gnucash/report/report-system/html-barchart.scm b/gnucash/report/report-system/html-barchart.scm
index 75ef17e..b6a04ad 100644
--- a/gnucash/report/report-system/html-barchart.scm
+++ b/gnucash/report/report-system/html-barchart.scm
@@ -141,7 +141,7 @@
;; AND:
;; To ensure that the generated subtitle doesn't contain any
;; unescaped quotes or backslashes, all strings must be freed
-;; from those by calling jqplot-escape-string.
+;; from those by calling gnc:html-string-sanitize.
;; Otherwise we're opening the gates again for bug 721768.
;;
;; Example: "\n" must be translated to "<br /> to introduce
@@ -150,9 +150,9 @@
;; Example call:
;; (gnc:html-barchart-set-subtitle! chart
;; (string-append "Bgt:"
-;; (jqplot-escape-string (number->string bgt-sum))
+;; (gnc:html-string-sanitize (number->string bgt-sum))
;; "<br /> Act:" ;; line break in the chart sub-title
-;; (jqplot-escape-string (number->string act-sum))))
+;; (gnc:html-string-sanitize (number->string act-sum))))
(define gnc:html-barchart-set-subtitle!
(record-modifier <html-barchart> 'subtitle))
@@ -372,9 +372,9 @@
(push "data.push(d")
(push series-index)
(push ");\n")
- (push "series.push({ label: \"")
- (push (jqplot-escape-string label))
- (push "\"});\n\n")))
+ (push (format #f "series.push({ label: ~s });\n\n"
+ (gnc:html-string-sanitize label)))
+ ))
; Use a unique chart-id for each chart. This prevents chart
; clashed on multi-column reports
(chart-id (string-append "chart-" (number->string (random 999999)))))
@@ -485,16 +485,13 @@
"false;\n"))
(if title
- (begin
- (push " options.title = \"")
- (push (jqplot-escape-string title))
- (push "\";\n")))
+ (push (format #f " options.title = ~s;\n"
+ (gnc:html-string-sanitize title))))
(if subtitle
- (begin
- (push " options.title += \" <br />")
- (push subtitle)
- (push "\";\n")))
+ (push (format #f " options.title += ' <br />' + ~s;\n"
+ (gnc:html-string-sanitize subtitle))))
+
(if (and (string? x-label) (> (string-length x-label) 0))
(begin
diff --git a/gnucash/report/report-system/html-linechart.scm b/gnucash/report/report-system/html-linechart.scm
index 7b0688d..44ebd40 100644
--- a/gnucash/report/report-system/html-linechart.scm
+++ b/gnucash/report/report-system/html-linechart.scm
@@ -408,9 +408,8 @@
(push "data.push(d")
(push series-index)
(push ");\n")
- (push "series.push({ label: \"")
- (push (jqplot-escape-string label))
- (push "\"});\n\n")))
+ (push (format #f "series.push({ label: ~s });\n\n"
+ (gnc:html-string-sanitize label)))))
; Use a unique chart-id for each chart. This prevents chart
; clashed on multi-column reports
(chart-id (string-append "chart-" (number->string (random 999999)))))
@@ -526,16 +525,12 @@
"false;\n"))
(if title
- (begin
- (push " options.title = \"")
- (push (jqplot-escape-string title))
- (push "\";\n")))
+ (push (format #f " options.title = ~s;\n"
+ (gnc:html-string-sanitize title))))
(if subtitle
- (begin
- (push " options.title += \" <br />")
- (push subtitle)
- (push "\";\n")))
+ (push (format #f " options.title += ' <br />' + ~s;\n"
+ (gnc:html-string-sanitize subtitle))))
(if (and (string? x-label) (> (string-length x-label) 0))
(begin
diff --git a/gnucash/report/report-system/html-piechart.scm b/gnucash/report/report-system/html-piechart.scm
index 9fd79e6..b93e526 100644
--- a/gnucash/report/report-system/html-piechart.scm
+++ b/gnucash/report/report-system/html-piechart.scm
@@ -231,11 +231,9 @@
(begin
(for-each
(lambda (datum label)
- (push " data.push(['")
- (push (jqplot-escape-string label))
- (push "',")
- (push datum)
- (push "]);\n"))
+ (push (format #f " data.push([~s,~a]);\n"
+ (gnc:html-string-sanitize label)
+ datum)))
data (gnc:html-piechart-labels piechart))))
(push "var options = {
@@ -253,15 +251,12 @@
};\n")
(if title
- (begin
- (push " options.title = \"")
- (push (jqplot-escape-string title))
- (push "\";\n")))
+ (push (format #f " options.title = ~s;\n"
+ (gnc:html-string-sanitize title))))
(if subtitle
- (begin
- (push " options.title += \" (")
- (push (jqplot-escape-string subtitle))
- (push ")\";\n")))
+ (push (format #f " options.title += ' (' + ~s + ')';\n"
+ (gnc:html-string-sanitize subtitle))))
+
(if (not (equal? colors-str ""))
(begin ; example: options.seriesColors= ["blue", "red"];
(push "options.seriesColors = [")
diff --git a/gnucash/report/standard-reports/budget-barchart.scm b/gnucash/report/standard-reports/budget-barchart.scm
index 6ba3697..1fadbc8 100644
--- a/gnucash/report/standard-reports/budget-barchart.scm
+++ b/gnucash/report/standard-reports/budget-barchart.scm
@@ -35,7 +35,6 @@
;; included since Bug726449
(use-modules (ice-9 regex)) ;; for regexp-substitute/global, used by jpqplot
-(load-from-path "html-jqplot") ;; for jqplot-escape-string
(define reportname
(N_ "Budget Chart"))
@@ -240,9 +239,9 @@
(if running-sum
(gnc:html-barchart-set-subtitle! chart
(string-append "Bgt:"
- (jqplot-escape-string (number->string bgt-sum))
+ (gnc:html-string-sanitize (number->string bgt-sum))
"<br /> Act:"
- (jqplot-escape-string (number->string act-sum))
+ (gnc:html-string-sanitize (number->string act-sum))
)
)
)
@@ -256,9 +255,9 @@
(if running-sum
(gnc:html-linechart-set-subtitle! chart
(string-append "Bgt:"
- (jqplot-escape-string (number->string bgt-sum))
+ (gnc:html-string-sanitize (number->string bgt-sum))
"<br /> Act:"
- (jqplot-escape-string (number->string act-sum))
+ (gnc:html-string-sanitize (number->string act-sum))
)
)
)
diff --git a/gnucash/report/standard-reports/category-barchart.scm b/gnucash/report/standard-reports/category-barchart.scm
index 342607c..ba23a97 100644
--- a/gnucash/report/standard-reports/category-barchart.scm
+++ b/gnucash/report/standard-reports/category-barchart.scm
@@ -28,16 +28,11 @@
(use-modules (gnucash report report-system collectors))
(use-modules (srfi srfi-1))
(use-modules (gnucash utilities))
-(use-modules (ice-9 regex))
(use-modules (gnucash gnc-module))
(use-modules (gnucash gettext))
(gnc:module-load "gnucash/report/report-system" 0)
-;; included since Bug726449
-(use-modules (ice-9 regex)) ;; for regexp-substitute/global, used by jpqplot
-(load-from-path "html-jqplot") ;; for jqplot-escape-string
-
;; The option names are defined here to 1. save typing and 2. avoid
;; spelling errors. The *reportnames* are defined here (and not only
;; once at the very end) because I need them to define the "other"
@@ -534,8 +529,8 @@ developing over time"))
(if do-intervals?
(_ "~a to ~a")
(_ "Balances ~a to ~a"))
- (jqplot-escape-string (qof-print-date from-date-t64))
- (jqplot-escape-string (qof-print-date to-date-t64))))
+ (gnc:html-string-sanitize (qof-print-date from-date-t64))
+ (gnc:html-string-sanitize (qof-print-date to-date-t64))))
(gnc:html-barchart-set-width! chart width)
(gnc:html-barchart-set-height! chart height)
@@ -560,8 +555,8 @@ developing over time"))
(if do-intervals?
(_ "~a to ~a")
(_ "Balances ~a to ~a"))
- (jqplot-escape-string (qof-print-date from-date-t64))
- (jqplot-escape-string (qof-print-date to-date-t64))))
+ (gnc:html-string-sanitize (qof-print-date from-date-t64))
+ (gnc:html-string-sanitize (qof-print-date to-date-t64))))
(gnc:html-linechart-set-width! chart width)
(gnc:html-linechart-set-height! chart height)
diff --git a/gnucash/report/standard-reports/net-barchart.scm b/gnucash/report/standard-reports/net-barchart.scm
index 53dd3ba..7479dbc 100644
--- a/gnucash/report/standard-reports/net-barchart.scm
+++ b/gnucash/report/standard-reports/net-barchart.scm
@@ -39,7 +39,6 @@
;; included since Bug726449
(use-modules (ice-9 regex)) ;; for regexp-substitute/global, used by jpqplot
-(load-from-path "html-jqplot") ;; for jqplot-escape-string
(define reportname (N_ "Income/Expense Chart"))
@@ -334,8 +333,8 @@
(gnc:html-barchart-set-subtitle!
chart (format #f
(_ "~a to ~a")
- (jqplot-escape-string (qof-print-date from-date-t64))
- (jqplot-escape-string (qof-print-date to-date-t64))))
+ (gnc:html-string-sanitize (qof-print-date from-date-t64))
+ (gnc:html-string-sanitize (qof-print-date to-date-t64))))
(gnc:html-barchart-set-width! chart width)
(gnc:html-barchart-set-height! chart height)
(gnc:html-barchart-set-row-labels! chart date-string-list)
diff --git a/gnucash/report/utility-reports/test-graphing.scm b/gnucash/report/utility-reports/test-graphing.scm
index 2d4052a..f375938 100644
--- a/gnucash/report/utility-reports/test-graphing.scm
+++ b/gnucash/report/utility-reports/test-graphing.scm
@@ -49,7 +49,7 @@
(let ((chart (gnc:make-html-barchart))
(text (gnc:make-html-text (gnc:html-markup-p "[bar goes here]"))))
(gnc:html-barchart-set-title! chart "Bar Chart Title")
- (gnc:html-barchart-set-subtitle! chart (jqplot-escape-string "Bar Chart SubTitle"))
+ (gnc:html-barchart-set-subtitle! chart (gnc:html-string-sanitize "Bar Chart SubTitle"))
(gnc:html-barchart-append-row! chart '(25 45 30))
(gnc:html-barchart-append-row! chart '(75 55 70))
(gnc:html-barchart-set-width! chart 320)
commit ea71c696c21d3868030bb7427f079e6b05c5d78e
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Wed Apr 25 13:34:45 2018 +0800
New function gnc:html-string-sanitize
Function to sanitize strings prior to adding to html report. This is
functionally similar to jqplot-escape-string, and is not locale sensitive.
diff --git a/gnucash/report/report-system/html-utilities.scm b/gnucash/report/report-system/html-utilities.scm
index 62224c2..feb8332 100644
--- a/gnucash/report/report-system/html-utilities.scm
+++ b/gnucash/report/report-system/html-utilities.scm
@@ -853,3 +853,17 @@
report-id
(_ "No data")
(_ "The selected accounts contain no data/transactions (or only zeroes) for the selected time period")))
+
+;; function to sanitize strings prior to sending to html
+(define (gnc:html-string-sanitize str)
+ (with-output-to-string
+ (lambda ()
+ (string-for-each
+ (lambda (c)
+ (display
+ (case c
+ ((#\&) "&")
+ ((#\<) "<")
+ ((#\>) ">")
+ (else c))))
+ str))))
diff --git a/gnucash/report/report-system/report-system.scm b/gnucash/report/report-system/report-system.scm
index 134ea26..bf4d036 100644
--- a/gnucash/report/report-system/report-system.scm
+++ b/gnucash/report/report-system/report-system.scm
@@ -119,6 +119,7 @@
(export gnc:html-make-generic-simple-warning)
(export gnc:html-make-empty-data-warning)
(export gnc:html-make-options-link)
+(export gnc:html-string-sanitize)
;; report.scm
(export gnc:menuname-reports)
diff --git a/gnucash/report/report-system/test/CMakeLists.txt b/gnucash/report/report-system/test/CMakeLists.txt
index 31c0b16..eea3423 100644
--- a/gnucash/report/report-system/test/CMakeLists.txt
+++ b/gnucash/report/report-system/test/CMakeLists.txt
@@ -15,6 +15,10 @@ SET(scm_test_report_system_SOURCES
test-list-extras.scm
test-report-utilities.scm
# test-test-extras.scm ;;FIXME why is this not run
+)
+
+set (scm_test_report_system_with_srfi64_SOURCES
+ test-html-utilities-srfi64.scm
)
set(GUILE_DEPENDS
@@ -29,6 +33,10 @@ set(GUILE_DEPENDS
)
GNC_ADD_SCHEME_TESTS(${scm_test_report_system_SOURCES})
+if (HAVE_SRFI64)
+ gnc_add_scheme_tests ("${scm_test_report_system_with_srfi64_SOURCES}")
+endif (HAVE_SRFI64)
+
GNC_ADD_SCHEME_TARGETS(scm-test-report-system
"test-extras.scm"
gnucash/report/report-system/test
@@ -46,7 +54,7 @@ GNC_ADD_SCHEME_TARGETS(scm-test-report-system-2
add_dependencies(check scm-test-report-system)
SET_DIST_LIST(test_report_system_DIST
CMakeLists.txt
-
+ ${scm_test_report_system_with_srfi64_SOURCES}
${scm_test_report_system_SOURCES}
test-extras.scm
test-link-module.c
diff --git a/gnucash/report/report-system/test/test-html-utilities-srfi64.scm b/gnucash/report/report-system/test/test-html-utilities-srfi64.scm
new file mode 100644
index 0000000..5c46793
--- /dev/null
+++ b/gnucash/report/report-system/test/test-html-utilities-srfi64.scm
@@ -0,0 +1,74 @@
+(use-modules (gnucash gnc-module))
+
+(gnc:module-begin-syntax (gnc:module-load "gnucash/app-utils" 0))
+(gnc:module-begin-syntax (gnc:module-load "gnucash/report/report-system" 0))
+
+(use-modules (gnucash engine test test-extras))
+(use-modules (gnucash report report-system test test-extras))
+(use-modules (gnucash report report-system))
+(use-modules (srfi srfi-64))
+
+(define (test-runner)
+ (let ((runner (test-runner-null))
+ (num-passed 0)
+ (num-failed 0))
+ (test-runner-on-test-end! runner
+ (lambda (runner)
+ (format #t "[~a] line:~a, test: ~a\n"
+ (test-result-ref runner 'result-kind)
+ (test-result-ref runner 'source-line)
+ (test-runner-test-name runner))
+ (case (test-result-kind runner)
+ ((pass xpass) (set! num-passed (1+ num-passed)))
+ ((fail xfail)
+ (if (test-result-ref runner 'expected-value)
+ (format #t "~a\n -> expected: ~s\n -> obtained: ~s\n"
+ (string-join (test-runner-group-path runner) "/")
+ (test-result-ref runner 'expected-value)
+ (test-result-ref runner 'actual-value)))
+ (set! num-failed (1+ num-failed)))
+ (else #t))))
+ (test-runner-on-final! runner
+ (lambda (runner)
+ (format #t "Source:~a\npass = ~a, fail = ~a\n"
+ (test-result-ref runner 'source-file) num-passed num-failed)
+ (zero? num-failed)))
+ runner))
+
+(define (run-test)
+ (test-runner-factory test-runner)
+ (test-begin "test-html-utilities-srfi64.scm")
+ (test-gnc:html-string-sanitize)
+ (test-end "test-html-utilities-srfi64.scm"))
+
+(define (test-gnc:html-string-sanitize)
+ (test-begin "gnc:html-string-sanitize")
+ (test-equal "null test"
+ "abc"
+ (gnc:html-string-sanitize "abc"))
+
+ (test-equal "sanitize ©"
+ "©"
+ (gnc:html-string-sanitize "©"))
+
+ (test-equal "emoji unchanged"
+ "🎃"
+ (gnc:html-string-sanitize "🎃"))
+
+ (test-equal "complex string"
+ "Smiley:\"🙂\" something"
+ (gnc:html-string-sanitize "Smiley:\"🙂\" something"))
+
+ (test-equal "sanitize <b>bold tags</b>"
+ "<b>bold tags</b>"
+ (gnc:html-string-sanitize "<b>bold tags</b>"))
+
+ (test-equal "quotes are unchanged for html"
+ "\""
+ (gnc:html-string-sanitize "\""))
+
+ (test-equal "backslash is unchanged for html"
+ "\\"
+ (gnc:html-string-sanitize "\\"))
+
+ (test-end "gnc:html-string-sanitize"))
Summary of changes:
gnucash/report/report-system/CMakeLists.txt | 1 -
gnucash/report/report-system/html-barchart.scm | 39 +++---------
gnucash/report/report-system/html-jqplot.scm | 44 -------------
gnucash/report/report-system/html-linechart.scm | 19 +++---
gnucash/report/report-system/html-piechart.scm | 23 +++----
gnucash/report/report-system/html-scatter.scm | 12 ++--
gnucash/report/report-system/html-utilities.scm | 24 +++++++
gnucash/report/report-system/report-system.scm | 3 +
gnucash/report/report-system/test/CMakeLists.txt | 10 ++-
.../test/test-html-utilities-srfi64.scm | 74 ++++++++++++++++++++++
.../report/standard-reports/account-piecharts.scm | 1 -
.../report/standard-reports/budget-barchart.scm | 25 ++------
.../report/standard-reports/category-barchart.scm | 13 ++--
gnucash/report/standard-reports/daily-reports.scm | 1 -
gnucash/report/standard-reports/net-barchart.scm | 8 +--
gnucash/report/utility-reports/test-graphing.scm | 2 +-
16 files changed, 153 insertions(+), 146 deletions(-)
delete mode 100644 gnucash/report/report-system/html-jqplot.scm
create mode 100644 gnucash/report/report-system/test/test-html-utilities-srfi64.scm
More information about the gnucash-changes
mailing list