From: David Levine Date: Wed, 19 Feb 2014 01:16:39 +0000 (-0600) Subject: Removed leading "exec " inserted in show_content_aux2(), which X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/06ed9c6e80c0dacf0c03832522498ea852260cb1?hp=db50a93031e37e78e38b318c40a2d4a045b72900 Removed leading "exec " inserted in show_content_aux2(), which allows use of shell expansion on Content-Type parameters in mhshow display straings. --- diff --git a/etc/mhn.defaults.sh b/etc/mhn.defaults.sh index 810b35c8..cbe72157 100755 --- a/etc/mhn.defaults.sh +++ b/etc/mhn.defaults.sh @@ -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 diff --git a/test/mhshow/test-textcharset b/test/mhshow/test-textcharset index 208d6c33..eafb6ad0 100755 --- a/test/mhshow/test-textcharset +++ b/test/mhshow/test-textcharset @@ -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 diff --git a/uip/mhshowsbr.c b/uip/mhshowsbr.c index 5a6f125e..d87cd932 100644 --- a/uip/mhshowsbr.c +++ b/uip/mhshowsbr.c @@ -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