diff options
-rwxr-xr-x | bollux | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/bollux b/bollux index ce80322..63dfe85 100755 --- a/bollux +++ b/bollux | |||
@@ -9,6 +9,7 @@ PRGN="${0##*/}" | |||
9 | VRSN=0.2.2 | 9 | VRSN=0.2.2 |
10 | # State | 10 | # State |
11 | REDIRECTS=0 | 11 | REDIRECTS=0 |
12 | set -f | ||
12 | 13 | ||
13 | bollux_usage() { | 14 | bollux_usage() { |
14 | cat <<END | 15 | cat <<END |
@@ -350,25 +351,25 @@ handle_response() { | |||
350 | } | 351 | } |
351 | 352 | ||
352 | display() { | 353 | display() { |
353 | case "$1" in | 354 | # split header line |
354 | *\;*) | 355 | local -a hdr |
355 | mime="${1%;*}" | 356 | IFS=$'\n' read -d "" -ra hdr <<<"${1//;/$'\n'}" |
356 | charset="${1#*;}" | 357 | |
357 | trim "$mime" | 358 | mime="${hdr[0],,}" |
358 | trim "$charset" | 359 | for h in "${hdr[@]}"; do |
359 | log d "$mime $charset" | 360 | h="$(trim "$h")" |
360 | ;; | 361 | log d "$h" |
361 | *) mime="$(trim "$1")" ;; | 362 | case "$h" in |
362 | esac | 363 | charset=*) charset="${h#charset=}" ;; |
364 | esac | ||
365 | done | ||
363 | 366 | ||
364 | [[ -z "$mime" ]] && mime="text/gemini" | 367 | [[ -z "$mime" ]] && mime="text/gemini" |
365 | if [[ -z "$charset" ]]; then | 368 | if [[ -z "$charset" ]]; then |
366 | charset="utf-8" | 369 | charset="utf-8" |
367 | else | ||
368 | charset="${charset#charset=}" | ||
369 | fi | 370 | fi |
370 | 371 | ||
371 | log debug "mime=$mime; charset=$charset" | 372 | log debug "mime='$mime'; charset='$charset'" |
372 | 373 | ||
373 | case "$mime" in | 374 | case "$mime" in |
374 | text/*) | 375 | text/*) |
@@ -387,6 +388,7 @@ display() { | |||
387 | log d "typeset_$submime" | 388 | log d "typeset_$submime" |
388 | { | 389 | { |
389 | normalize_crlf | | 390 | normalize_crlf | |
391 | iconv -f "${charset^^}" -t "UTF-8" - | | ||
390 | tee "$BOLLUX_PAGESRC" | | 392 | tee "$BOLLUX_PAGESRC" | |
391 | run "typeset_$submime" | | 393 | run "typeset_$submime" | |
392 | run "${less_cmd[@]}" | 394 | run "${less_cmd[@]}" |
@@ -395,6 +397,7 @@ display() { | |||
395 | log "cat" | 397 | log "cat" |
396 | { | 398 | { |
397 | normalize_crlf | | 399 | normalize_crlf | |
400 | iconv -f "${charset^^}" -t "UTF-8" - | | ||
398 | tee "$BOLLUX_PAGESRC" | | 401 | tee "$BOLLUX_PAGESRC" | |
399 | run "${less_cmd[@]}" | 402 | run "${less_cmd[@]}" |
400 | } || run handle_keypress "$?" | 403 | } || run handle_keypress "$?" |