1.0.0-0.fdr.3 - fix security vulnerability (CAN-2004-0645) 1.0.0-0.fdr.2 - add several patches - depend on glib2 (bug 1592) 1.0.0-0.fdr.1 - initial RPM (from Mandrake)
107 lines
2.5 KiB
Diff
107 lines
2.5 KiB
Diff
--- wvText.in
|
|
+++ wvText.in
|
|
@@ -3,24 +3,50 @@
|
|
prefix=@prefix@
|
|
exec_prefix=@exec_prefix@
|
|
datadir=@datadir@
|
|
-tmpdir=/tmp
|
|
+tmpdir=$(mktemp -d /tmp/wvText.XXXXXXXX) || { echo "$0: can not create temporary directory" >& 2; exit 1; }
|
|
+i_file=
|
|
+o_file=
|
|
|
|
# argument checking
|
|
-if [ ${#} -ne "2" ]; then
|
|
- echo "Usage: ${0} <word document> <text output file>"
|
|
+
|
|
+case ${#} in
|
|
+ 1)
|
|
+ i_file=${1}
|
|
+ o_file=-
|
|
+ ;;
|
|
+ 2)
|
|
+ i_file=${1}
|
|
+ o_file=${2}
|
|
+ ;;
|
|
+ *)
|
|
+ echo "Usage: `basename ${0}` <word document> [<text output file>]"
|
|
exit 1
|
|
-fi
|
|
+ ;;
|
|
+esac
|
|
|
|
# start out optimistic
|
|
-USING_LYNX=1
|
|
-which lynx >/dev/null 2>&1
|
|
-if [ ${?} -ne "0" ]; then
|
|
- echo "Could not find required program 'lynx'"
|
|
- echo "Not using lynx. Ouput will be pretty bad."
|
|
- USING_LYNX=0
|
|
-fi
|
|
+USING_BROWSER=1
|
|
+BROWSER_CMD="w3m -dump -T text/html"
|
|
+browser=none
|
|
+
|
|
+which lynx >& /dev/null && browser=lynx
|
|
+which w3m >& /dev/null && browser=w3m
|
|
+
|
|
+case $browser in
|
|
+ w3m)
|
|
+ BROWSER_CMD="w3m -dump -T text/html"
|
|
+ ;;
|
|
+ lynx)
|
|
+ BROWSER_CMD="lynx -dump -force_html"
|
|
+ ;;
|
|
+ *)
|
|
+ echo "Neither w3m nor lynx found"
|
|
+ echo "Output will be pretty bad."
|
|
+ USING_BROWSER=0
|
|
+ ;;
|
|
+esac
|
|
|
|
-if [ ${USING_LYNX} -ne "0" ]; then
|
|
+if [ ${USING_BROWSER} -ne "0" ]; then
|
|
|
|
# first, test for wvHtml
|
|
which wvHtml >/dev/null 2>&1
|
|
@@ -32,25 +58,34 @@
|
|
# intermediate file
|
|
TMP_FILE="wv$$.html"
|
|
|
|
- wvHtml "${1}" --targetdir="${tmpdir}" "${TMP_FILE}" >/dev/null 2>&1
|
|
+ wvHtml "$i_file" --targetdir="${tmpdir}" "${TMP_FILE}" >/dev/null 2>&1
|
|
if [ ${?} -ne "0" ]; then
|
|
- echo "Could not convert into HTML"
|
|
+ echo "Could not convert $i_file into HTML"
|
|
exit 1
|
|
fi
|
|
|
|
# lynx actually does quite well
|
|
- TERM=vt100 lynx -dump -force_html "${tmpdir}/${TMP_FILE}" > "${2}"
|
|
+ # Output to stdout requested
|
|
+ if test "x$o_file" = "x-"; then
|
|
+ TERM=vt100 ${BROWSER_CMD} "${tmpdir}/${TMP_FILE}"
|
|
+ else
|
|
+ TERM=vt100 ${BROWSER_CMD} "${tmpdir}/${TMP_FILE}" > "$o_file"
|
|
+ fi
|
|
if [ ${?} -ne "0" ]; then
|
|
- echo "Could not convert into Text"
|
|
+ echo "Could not convert $i_file into Text"
|
|
exit 1
|
|
fi
|
|
|
|
# clean up
|
|
- rm -f "${tmpdir}/${TMP_FILE}"
|
|
+ rm -rf "${tmpdir}"
|
|
|
|
else
|
|
# fall back onto our cruddy output
|
|
# this is, admittedly, better than running
|
|
# 'strings' on the word document though :)
|
|
- wvWare -x ${datadir}/wv/wvText.xml "${1}" > "${2}"
|
|
+ if test "x$o_file" = "x-"; then
|
|
+ wvWare -x ${datadir}/wv/wvText.xml "$i_file"
|
|
+ else
|
|
+ wvWare -x ${datadir}/wv/wvText.xml "$i_file" > "$o_file"
|
|
+ fi
|
|
fi
|
|
|