mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-11-25 10:20:18 -06:00
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
This commit is contained in:
parent
0057027153
commit
b435ee60c0
@ -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
|
||||
|
@ -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"))
|
||||
|
Loading…
Reference in New Issue
Block a user