]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
Bug 901: mimeencoding bug in templates handling
authorAidan Van Dyk <aidan@ifax.com>
Fri, 6 Feb 2009 21:14:01 +0000 (21:14 +0000)
committerAidan Van Dyk <aidan@ifax.com>
Fri, 6 Feb 2009 21:14:01 +0000 (21:14 +0000)
Be more careful about locale and encoding issues

doc/RELEASENOTES-4.4.txt
util/common-functions.sh.in

index 855777cd921dfe092d1dc68063e5b5dae2e434b9..e8c7cabd64a36d60a0254cedc1317915e0c181a2 100644 (file)
@@ -149,3 +149,4 @@ CHANGES since 4.4.4
 * Abort receive session on error writing to file (2008-11-21)
 * Bug 902: Fix non-void function without a return (2009-02-02)
 * b64-encode.awk: Fix bug on old SCO awk (2009-01-30)
+* Bug 901: mimeencoding bug in templates handling (2009-02-06)
index 308f54e39cf316ca4be11dc5c27d32ea758bed81..cb3c1e34c763b8e2f9614e0ba177fd586cb8c611 100644 (file)
@@ -185,10 +185,10 @@ mimeEncode()
                if [ -x "$cmd" ]; then
                    (eval $BASE64ENCODE) < $1 2>$ERRORSTO
                else
-                   $AWK -f bin/b64-encode.awk < $1 2>$ERRORSTO
+                   $AWK -f bin/b64-encode.awk < $1 2>$ERRORSTO
                fi
            else
-               $AWK -f bin/b64-encode.awk < $1 2>$ERRORSTO
+               $AWK -f bin/b64-encode.awk < $1 2>$ERRORSTO
            fi;;
         quoted-printable)
            if [ -n "$QPENCODE" ]; then
@@ -197,10 +197,10 @@ mimeEncode()
                if [ -x "$cmd" ]; then
                    (eval $QPENCODE) < $1 2>$ERRORSTO
                else
-                   $AWK -f bin/qp-encode.awk < $1 2>$ERRORSTO
+                   $AWK -f bin/qp-encode.awk < $1 2>$ERRORSTO
                fi
            else
-               $AWK -f bin/qp-encode.awk < $1 2>$ERRORSTO
+               $AWK -f bin/qp-encode.awk < $1 2>$ERRORSTO
            fi;;
         *uue*)
            if [ -x "$UUENCODE" ]; then
@@ -222,8 +222,8 @@ matchRegEx()
   # Awk grep and sed ranges can't be trusted to gives the same result
   # on all platforms and locale. :( (Even for digit ranges...
   # fractions can be included in the 0-1 range.)
-  # Forcing LC_ALL to C should be enough to fix this.
-  echo $string | LC_ALL=C $AWK -F=!=!=!=!=!=!=!=!= '
+  # Using C locale should be enough to fix this.
+  echo $string | c $AWK -F=!=!=!=!=!=!=!=!= '
     '$regex' {print 1; exit;}
     {print 0;}'
 
@@ -255,7 +255,7 @@ headerEncode()
     case $position in 
       phrase)
         if [ `matchRegEx "$string" '/^[\0-\177]*$/'` = 1 ]; then
-          echo $string | LC_ALL=C $AWK -F=!=!=!=!=!=!=!=!= '
+          echo $string | c $AWK -F=!=!=!=!=!=!=!=!= '
           function simple_quote(text)
           {
               gsub(/[\0-\37\177\\\"]/, "\\\\&", text);
@@ -288,8 +288,8 @@ headerEncode()
     esac
 
     if [ $must_encode = true ]; then
-      encoded=" =?UTF-8?B?`echo $string | $AWK -f bin/b64-encode.awk 2>$ERRORSTO`?="
-      echo $encoded
+      encoded=" =?UTF-8?B?`echo $string | $AWK -f bin/b64-encode.awk 2>$ERRORSTO`?="
+      echo $encoded | $SED -e 's/ //g'
     else
       echo $string
     fi
@@ -689,6 +689,12 @@ hfExit ()
     exit $1
 }
 
+# Basic function for running utilitis with C locale
+c ()
+{
+        LC_ALL=C "$@"
+}
+
 # And some common variables for things using our functions
 if [ -z "$TEMPLATE" ]
 then