From eb1ab3df90bbc3a032bd09c1057a5417e637c0ca Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 14 Nov 2017 02:01:57 +0100 Subject: [PATCH] braille: Fix handling non-printable characters BRF files may contain SUBs for EOF, which we should just ignore, or FFs, which we should just print. Other non-printable characters are not supposed to appear. --- .../braille/drivers/index/textbrftoindexv3.in | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/filter/braille/drivers/index/textbrftoindexv3.in b/filter/braille/drivers/index/textbrftoindexv3.in index af46c8ab3..8ec0a1fb7 100755 --- a/filter/braille/drivers/index/textbrftoindexv3.in +++ b/filter/braille/drivers/index/textbrftoindexv3.in @@ -61,6 +61,31 @@ then do # Strip CRs LINE=${LINE//$'\015'} + # Ignore SUBs + LINE=${LINE//$'\032'} + + # Interpret FFs + while [ -n "$LINE" -a -z "${LINE/#$'\014'*}" ] + do + printf "\\f" + LINE=${LINE#$'\014'} + done + + # Make sure there is nothing else we don't process + if [ -n "$LINE" ] + then + if [ -z "${LINE/*[$'\001'-$'\037'$'\177']*}" ] + then + echo "ERROR: unsupported control character in BRF file" >&2 + exit 1 + fi + if [ -z "${LINE/*[$'\200'-$'\377']*}" ] + then + echo "ERROR: unsupported non-ASCII character in BRF file" >&2 + exit 1 + fi + fi + CHARS=$(printf %s "$LINE" | wc -c) if [ "$CHARS" -gt 127 ] then -- 2.47.2