Merge pull request #1499 from dcooper16/fix_printing_percent

Fix printing percent characters
This commit is contained in:
Dirk Wetter 2020-03-06 14:35:31 +01:00 committed by GitHub
commit 6f02101ae0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 7 deletions

View File

@ -501,17 +501,16 @@ html_reserved(){
html_out() { html_out() {
"$do_html" || return 0 "$do_html" || return 0
[[ -n "$HTMLFILE" ]] && [[ ! -d "$HTMLFILE" ]] && printf -- "%b" "${1//%/%%}" >> "$HTMLFILE" [[ -n "$HTMLFILE" ]] && [[ ! -d "$HTMLFILE" ]] && printf -- "%b" "$1" >> "$HTMLFILE"
# here and other printf's: a little bit of sanitizing with bash internal search&replace -- otherwise printf will hiccup at '%'. '--' and %b do the rest.
} }
# This is intentionally the same. # This is intentionally the same.
safe_echo() { printf -- "%b" "${1//%/%%}"; } safe_echo() { printf -- "%b" "$1"; }
tm_out() { printf -- "%b" "${1//%/%%}"; } tm_out() { printf -- "%b" "$1"; }
tmln_out() { printf -- "%b" "${1//%/%%}\n"; } tmln_out() { printf -- "%b" "$1\n"; }
out() { printf -- "%b" "${1//%/%%}"; html_out "$(html_reserved "$1")"; } out() { printf -- "%b" "$1"; html_out "$(html_reserved "$1")"; }
outln() { printf -- "%b" "${1//%/%%}\n"; html_out "$(html_reserved "$1")\n"; } outln() { printf -- "%b" "$1\n"; html_out "$(html_reserved "$1")\n"; }
#TODO: Still no shell injection safe but if just run it from the cmd line: that's fine #TODO: Still no shell injection safe but if just run it from the cmd line: that's fine