On Fri, 15 Mar 2002, Gilles Detillieux wrote: > Date: Fri, 15 Mar 2002 09:49:47 -0600 (CST) > From: Gilles Detillieux <[EMAIL PROTECTED]> > To: "Joe R. Jah" <[EMAIL PROTECTED]> > Cc: "ht://Dig developers list" <[EMAIL PROTECTED]> > Subject: Re: [htdig-dev] "file name.html" -> "filename.html";( > > Well, there's no "shift" method in the String class, nor anything that > simply strips characters off the front of a String. However, did you not > see my reply to Jessica Biola yesterday afternoon, in this same thread?
I saw it, but I had not read it through until now;) > I did cc the list. In that, I suggested a simple fix to advance the > char * pointer past leading spaces before assigning to temp. It works like a charm;) thanks Gilles, the patch: ------------------------8<------------------------ *** htlib/URL.cc.orig Thu Feb 7 17:15:38 2002 --- htlib/URL.cc Fri Mar 15 12:15:41 2002 *************** *** 74,81 **** // URL::URL(char *ref, URL &parent) { String temp(ref); ! temp.remove(" \r\n\t"); ref = temp; _host = parent._host; --- 74,84 ---- // URL::URL(char *ref, URL &parent) { + while (*ref == ' ') + ref++; String temp(ref); ! temp.remove("\r\n\t"); ! temp.chop(' '); ref = temp; _host = parent._host; *************** *** 248,255 **** // void URL::parse(char *u) { String temp(u); ! temp.remove(" \t\r\n"); char *nurl = temp; // --- 251,261 ---- // void URL::parse(char *u) { + while (*u == ' ') + u++; String temp(u); ! temp.remove("\r\n\t"); ! temp.chop(' '); char *nurl = temp; // ------------------------8<------------------------ > > And somehow turning the rest of the space into %20 in the code? > > OK, this is a little bit more effort, because now you're expanding a > single character into 3, so you can't do it in place. However, you > could probably change the first few lines of the URL constructor and > parse methods like this. First, change the "u" to "ref" in the parse > method for consistency. Then, instead of simply assigning ref to temp > as String temp(ref); and then removing white space characters, you can > do this: The above patch already allows in non-(leading/trailing) space. The code bellow would just convert the allowed space into %20. I believe the term allow_space_in_url would be more expressive as convert_space_to_%20, or something;) > 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++; > } > > > Then, you'll have to set allow_space_in_url: true in your htdig.conf > to enable this feature. At any case, I do not see the rationale behind this option. We do not give an option for allowing non-(leading/trailing) space, but we give one for converting them to %20;-/ Unless we somehow integrate your option, allow_space_in_url, in the entire patch;) Regards, Joe -- _/ _/_/_/ _/ ____________ __o _/ _/ _/ _/ ______________ _-\<,_ _/ _/ _/_/_/ _/ _/ ......(_)/ (_) _/_/ oe _/ _/. _/_/ ah [EMAIL PROTECTED] _______________________________________________ htdig-dev mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/htdig-dev