Date: Fri, 15 Mar 2002 19:35:54 -0800 (PST)
From: "Joe R. Jah" <jjah@cloud.ccsf.cc.ca.us>
To: Gilles Detillieux <grdetil@scrc.umanitoba.ca>
Cc: "ht://Dig developers list" <htdig-dev@lists.sourceforge.net>
Subject: Re: [htdig-dev] "file name.html" -> "filename.html";(

On Fri, 15 Mar 2002, Gilles Detillieux wrote:

> Date: Fri, 15 Mar 2002 18:36:06 -0600 (CST)
> From: Gilles Detillieux <grdetil@scrc.umanitoba.ca>
> To: jjah@cloud.ccsf.cc.ca.us
> Cc: "ht://Dig developers list" <htdig-dev@lists.sourceforge.net>
> Subject: Re: [htdig-dev] "file name.html" -> "filename.html";(

> Here's your error right here.  You shouldn't have deleted that third
> line, only the first two.  The last one is needed because the constructor
> then uses the ref pointer to walk through the cleaned up URL string.
> You should set ref = temp; right after the close of the while loop
> below.
...
> You need...
>
>     ref = temp;
> 
> here, after the loop.  Without it, ref is still pointing to the end of
> the original URL, not the start of the cleaned up one, so the rest of
> the code will think it got an empty string as a URL.
...
> The second section, in URL::parse() looks fine to me, because in there,
> there were only two lines that you removed at the start, and you left
> the assignment of temp to nurl.

Thank you Gilles I corrected the patch and placed it in the patch site:

  ftp://ftp.ccsf.edu/htdig-patches/3.1.6/fileSpace.1
 
I believe this patch is safer than the fileSpace.0 because it does not
leave any space in the URL; besides, its use is optional.  I switch back   
my vote to +1;)

To apply save it to your srver, change to htdig-3.1.6 source directory,
and run		patch -p0 < /patch/to/fileSpace.1

*** htlib/URL.cc.031202	Thu Feb  7 17:15:38 2002
--- htlib/URL.cc	Fri Mar 15 17:04:21 2002
***************
*** 74,81 ****
  //
  URL::URL(char *ref, URL &parent)
  {
!     String	temp(ref);
!     temp.remove(" \r\n\t");
      ref = temp;
  
      _host = parent._host;
--- 74,97 ----
  //
  URL::URL(char *ref, URL &parent)
  {
!     static int  allowspace = config.Boolean("allow_space_in_url", 0);
!     String      temp;
!     while (*ref)
!     {
!         if (*ref == ' ' && temp.length() > 0 && allowspace)
!         {
!             // Replace space character with %20 if there's more non-space
!             // characters to come...
!             char *s = ref+1;
!             while (*s && isspace(*s))
!                 s++;
!             if (*s)
!                 temp << "%20";
!         }
!         else if (!isspace(*ref))
!             temp << *ref;
!         ref++;
!     }
      ref = temp;
  
      _host = parent._host;
***************
*** 243,255 ****
  }
  
  //*****************************************************************************
! // void URL::parse(char *u)
  //   Given a URL string, extract the service, host, port, and path from it.
  //
! void URL::parse(char *u)
  {
!     String	temp(u);
!     temp.remove(" \t\r\n");
      char	*nurl = temp;
  
      //
--- 259,287 ----
  }
  
  //*****************************************************************************
! // void URL::parse(char *ref)
  //   Given a URL string, extract the service, host, port, and path from it.
  //
! void URL::parse(char *ref)
  {
!     static int  allowspace = config.Boolean("allow_space_in_url", 0);
!     String      temp;
!     while (*ref)
!     {
!         if (*ref == ' ' && temp.length() > 0 && allowspace)
!         {
!             // Replace space character with %20 if there's more non-space
!             // characters to come...
!             char *s = ref+1;
!             while (*s && isspace(*s))
!                 s++;
!             if (*s)
!                 temp << "%20";
!         }
!         else if (!isspace(*ref))
!             temp << *ref;
!         ref++;
!     }
      char	*nurl = temp;
  
      //

