|
Trevor,
The magic number for Word documents (Word6 &
later) is \320\317\021\340, the same as Excel spreadsheets. That is
why doc2html.pl has to check both magic number and MIME-type.
I don't recognise '^\376\067\0\043',
could it be the magic number for some form of Word for MacIntosh
document?
Doc2html.pl should read the start of each file as
binary to get the magic number, but on some systems it reads it as text. Add a
line to sub read_magic so that it becomes:
open(FILE, "< $Input") || die "Can't open
file $Input\n";
binmode FILE;
read FILE,$Magic,256;
close FILE;
Let us know how you get on.
David Adams Corporate Information
Services Information Systems Services University of
Southampton
----- Original Message -----
Sent: Wednesday, July 21, 2004 10:38
PM
Subject: [htdig] Issues when parsing
msword docs
I'm working
upgrading to the new 3.2.0b6 version of htdig. Running into issues on when
parsing msword docs (doc, xls).
When running
doc2html.pl via command line directly on a word doc I see the $MAGIC
number's aren't being determined correctly for the doc
file. Instead of pulling: $magic = '^\376\067\0\043'; (word6,7/97)
it pulls: ��ࡱ�>��
.0����-�������(continuous)
Similar with
xls, when running doc2html.pl via command line the $MAGIC numbers aren't:
$magic = '^\320\317\021\340'; as expected but:
��ࡱ�>�� �������(continuous)
It looks like doc2html.pl is receiving these as
binary files instead text. Doing the command "file -i" on the documents
confirms the mime type to be application/msword for
both.
Doing a octal dump on the first line of the file does
reveal the correct $magic numbers:
$od -b /opt/htdig/contrib/doc2html/todays-news.doc |
head -1 0000000 320 317 021 340 241 261 032 341 000 000 000 000 000 000 000
000
Running the doc file directly through catdoc returns
pristine text output as does running the xls file directly through xls2csv.
Server is RH Linux Enterprise with perl
5.8.0
Any ideas on how to counter and/or correct this
problem?
Thanks for any
suggestions.
|