diff --git a/gnucash/report/report-system/html-barchart.scm b/gnucash/report/report-system/html-barchart.scm index 75ef17e133..b6a04ad9e6 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 "
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)) ;; "
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 '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 += \"
") - (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/report-system/html-linechart.scm b/gnucash/report/report-system/html-linechart.scm index 7b0688def0..44ebd40b1b 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 += \"
") - (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/report-system/html-piechart.scm b/gnucash/report/report-system/html-piechart.scm index 9fd79e6852..b93e526b18 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 6ba3697722..1fadbc8205 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)) "
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)) "
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 342607caa1..ba23a977b8 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 53dd3babaa..7479dbc472 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 2d4052a41e..f375938a53 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)