jqplot-escape-string -> gnc:html-string-sanitize

pull/344/head
Christopher Lam 8 years ago
parent ea71c696c2
commit fcb5f64bd5

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

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

@ -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 = [")

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

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

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

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

Loading…
Cancel
Save