]> diplodocus.org Git - nmh/commitdiff
Removed leading "exec " inserted in show_content_aux2(), which
authorDavid Levine <levinedl@acm.org>
Wed, 19 Feb 2014 01:16:39 +0000 (19:16 -0600)
committerDavid Levine <levinedl@acm.org>
Wed, 19 Feb 2014 01:16:39 +0000 (19:16 -0600)
allows use of shell expansion on Content-Type parameters in
mhshow display straings.

etc/mhn.defaults.sh
test/mhshow/test-textcharset
uip/mhshowsbr.c

index 810b35c..cbe7215 100755 (executable)
@@ -27,10 +27,12 @@ trap "rm -f $TMP" 0 1 2 3 13 15
 
 
 if [ ! -z "`$SEARCHPROG $SEARCHPATH w3m`" ]; then
-  echo "mhfixmsg-format-text/html: w3m -dump -T text/html -O utf-8 '%F'" >> $TMP
+  echo 'mhfixmsg-format-text/html: charset="%{charset}"; '"\
+"'w3m -dump -T text/html "${charset:+-I $charset}" -O utf-8 %F' >> $TMP
 elif [ ! -z "`$SEARCHPROG $SEARCHPATH lynx`" ]; then
   #### lynx indents with 3 spaces, remove them and any trailing spaces.
-  echo "mhfixmsg-format-text/html: lynx -child -dump -force_html '%F' | \
+  echo 'mhfixmsg-format-text/html: charset="%{charset}"; '"\
+"'lynx -child -dump -force_html "${charset:+--assume_charset $charset}" %F | '"\
 expand | sed -e 's/^   //' -e 's/  *$//'" >> $TMP
 elif [ ! -z "`$SEARCHPROG $SEARCHPATH elinks`" ]; then
   echo "mhfixmsg-format-text/html: elinks -dump -force-html -no-numbering \
@@ -237,11 +239,13 @@ EOF
 # that another netscape is already running and certain things can't be done).
 PGM="`$SEARCHPROG $SEARCHPATH lynx`"
 if [ ! -z "$PGM" ]; then
-       echo "mhshow-show-text/html: %p$PGM -force-html '%F'" >> $TMP
+       echo 'mhshow-show-text/html: charset="%{charset}"; '"\
+%p$PGM"' -force-html "${charset:+--assume_charset $charset}" %F' >> $TMP
 else
   PGM="`$SEARCHPROG $SEARCHPATH w3m`"
   if [ ! -z "$PGM" ]; then
-       echo "mhshow-show-text/html: %p$PGM -T text/html '%F'" >> $TMP
+       echo 'mhshow-show-text/html: charset="%{charset}"; '"\
+%p$PGM"' "${charset:+-I $charset}" -T text/html %F' >> $TMP
   fi
 fi
 
index 208d6c3..eafb6ad 100755 (executable)
@@ -16,9 +16,6 @@ fi
 
 setup_test
 
-#### Use ap from PATH.
-PATH=`mhparam libdir`:$PATH
-
 if test "$ICONV_ENABLED" -eq 0; then
   test_skip 'test-textcharset requires that nmh have been built with iconv'
 fi
@@ -120,7 +117,7 @@ check "$expected" "$actual"
 grep -v 'mhshow-show-text/plain:' "$MH" >"$MH.new"
 mv -f "$MH.new" "$MH"
 cat >>"$MH" <<'EOF'
-mhshow-show-text/plain: echo `ap -format '%(void(lit %{charset}))%<(nonnull)-I %(putstr)%>' 0`
+mhshow-show-text/plain: charset="%{charset}"; echo ${charset:+-I $charset}
 EOF
 
 # check expansion of embedded %{charset} with no text following
index 5a6f125..d87cd93 100644 (file)
@@ -359,7 +359,7 @@ show_content_aux2 (CT ct, int serial, int alternate, char *cracked, char *buffer
 {
     pid_t child_id;
     int i;
-    char *vec[4], exec[BUFSIZ + sizeof "exec "];
+    char *vec[4];
 
     if (debugsw || cracked) {
        fflush (stdout);
@@ -411,11 +411,9 @@ show_content_aux2 (CT ct, int serial, int alternate, char *cracked, char *buffer
        }
     }
 
-    snprintf (exec, sizeof(exec), "exec %s", buffer);
-
     vec[0] = "/bin/sh";
     vec[1] = "-c";
-    vec[2] = exec;
+    vec[2] = buffer;
     vec[3] = NULL;
 
     fflush (stdout);
@@ -898,9 +896,20 @@ parse_display_string (CT ct, char *cp, int *xstdin, int *xlist, int *xpause,
                       just increment by 1 for the '{'. */
                    cp += strlen(param) + 1;
 
-                   /* cp points to the param and it's set in the
+                   /* cp pointed to the param and it's set in the
                       Content-Type header. */
                    strncpy (bp, value, buflen);
+
+                   /* since we've quoted the file argument, set things up
+                    * to look past it, to avoid problems with the quoting
+                    * logic below.  (I know, I should figure out what's
+                    * broken with the quoting logic, but..)
+                    */
+                   len = strlen(bp);
+                   buflen -= len;
+                   bp += len;
+                   pp = bp;
+
                    break;
                } else if (found == 1) {
                    /* cp points to the param and it's not set in the
@@ -927,7 +936,7 @@ parse_display_string (CT ct, char *cp, int *xstdin, int *xlist, int *xpause,
                    *bp++ = '{';
                    *bp = '\0';
                    buflen -= 2;
-                   break;
+                   continue;
                }
 
                /* No parameter was found, so fall thru to default to