line&bar chart subtitles are always sanitized

This obviates bug 726449 for consistency
This commit is contained in:
Christopher Lam
2018-04-28 00:35:53 +08:00
parent ba2c1f6a05
commit 583c0217c4
3 changed files with 9 additions and 40 deletions

View File

@@ -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))

View File

@@ -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

View File

@@ -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)))
)
)
)