Improve rcldoc filter and switch back to using it for indexing instead of direct antiword exec. This is slightly slower but it does catch a number of .doc files which would not be indexed otherwise
This commit is contained in:
+33
-10
@@ -102,15 +102,18 @@ checkcmds awk antiword iconv
|
||||
$decoder "$infile" |
|
||||
awk 'BEGIN'\
|
||||
' {
|
||||
print "<html><head><title></title>"
|
||||
print "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\">"
|
||||
print "</head>\n<body>\n<p>"
|
||||
cont = ""
|
||||
gotdata = 0
|
||||
}
|
||||
{
|
||||
if (!($0 ~ /^[ ]*$/))
|
||||
if (!($0 ~ /^[ ]*$/)) {
|
||||
gotdata = 1
|
||||
if (gotdata == 0) {
|
||||
print "<html><head><title></title>"
|
||||
print "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\">"
|
||||
print "</head>\n<body>\n<p>"
|
||||
}
|
||||
}
|
||||
$0 = cont $0
|
||||
cont = ""
|
||||
|
||||
@@ -139,12 +142,32 @@ END {
|
||||
print "</p></body></html>"
|
||||
}'
|
||||
|
||||
# wvWare is much slower and we don't use it by default, but it handles
|
||||
# some files that antiword won't, so use it as a last resort. Yes the
|
||||
# html document will have a second header section, but this doesn't
|
||||
# seem to be an issue with our brave html input handler...
|
||||
|
||||
# Antiword rarely fails, we try to catch the most common reasons:
|
||||
if test $? -eq 1 ; then
|
||||
if iscmd wvWare ; then
|
||||
wvWare --nographics --charset=utf-8 "$infile"
|
||||
# Check actual document type
|
||||
mtype=`file -b -i "$infile" | awk '{sub(";", "", $1);print $1}'`
|
||||
|
||||
if test X"$mtype" = Xtext/rtf; then
|
||||
# RTF document disguising as msword either because it has a .doc
|
||||
# extension or because it's an attachment with a wrong mime.
|
||||
exec `dirname $0`/rclrtf $infile
|
||||
fi
|
||||
|
||||
if test X"$mtype" = Xtext/plain; then
|
||||
# Someone gave a .doc ext to their texts. Happens...
|
||||
exec `dirname $0`/rcltext $infile
|
||||
fi
|
||||
|
||||
if test X"$mtype" = Xapplication/msword; then
|
||||
# Actually application/msword: try wvWare, which is much
|
||||
# slower and we don't use it by default, but it handles some
|
||||
# files that antiword won't, so use it as a last resort.
|
||||
if iscmd wvWare ; then
|
||||
exec wvWare --nographics --charset=utf-8 "$infile"
|
||||
fi
|
||||
fi
|
||||
|
||||
# else let the error be...
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user