RE: Infinite Loop...

Hi Giacomo,

>        In the LineMode, Webbot, and ComLine, I try that in some case they
> go into infinite loop. If my local host is named : A.B.C and I try to run
> (examples) :
>         webbot file://D.E.F/     or
>         www    file://D.E.F/     or
>         w3c    file://D.E.F/
>         where A.B.C != D.E.F    ( C-like sintax )
>         that application run infinitely and go into a Segmentation Fault.

I bumped into the similar problem several months ago, corrected it quickly
and forgot to send a patch to Henrik. :-(  The problem was caused by small but
severe bug in the HTFile.c module. It seems that this bug is still there, so perhaps
my old patch will help you. I'm not using the latest version of the library, so please
let me know if the following patch corrects the problem (for 4.0pre4 it does).

"file:" URLs are handled by HTFile module, which reads files from the local system.
However when the URL includes a host name, different from your local computer
name, HTFile module tries FTP to access the requested object. This is done
in the following fragment of the HTFile.c file (part of the HTLoadFile function):

          case FS_TRY_FTP:
                char *url = HTAnchor_physical(anchor);
                HTAnchor *anchor;
                char *newname = NULL;
                StrAllocCopy(newname, "ftp:");
                if (!strncmp(url, "file:", 5))
                    StrAllocCat(newname, url+5);
                    StrAllocCat(newname, url);
                anchor = HTAnchor_findAddress(newname);   /* (1) */
                FileCleanup(request, HT_IGNORE);   /* (2) */
                return HTLoad(request, YES);           /* (3) */

In the line (1) a new "ftp:" anchor is created. The problem is that this anchor isn't 
assigned to the request. This causes infinite recursion, because HTLoad is called
with the unmodified request (see line (3)) and this call finally lands in HTLoadFile 

To correct this I added the following line after a line (2):

                HTRequest_setAnchor(request, anchor);

I hope this will help.

Best regards

Maciej Puzio