Re: backslashes in config and change of strwordtok()

From: Evgeny Kotsuba <evgen__k@dont-contact.us>
Date: Wed, 26 Jan 2005 02:41:28 +0300

On Wed, 26 Jan 2005 00:08:47 +0100 (CET)
  Henrik Nordstrom <hno@squid-cache.org> wrote:
> On Wed, 26 Jan 2005, Evgeny Kotsuba wrote:
>
>> What is the reason for last changes in strwordtok() (tools.c
>>/tools.cc) ?
>
> To support the external_acl protocol in a more robust manner.
>
>> I.e is it now
>> * Similar to strtok, but has some rudimentary knowledge of quoting
>> or it makes something more ?
>>
>> This changes with case '\\': boke possibilitiy to put in
>>config paths
>> with backslashes i.e.. native form of paths for OS/2 and
>>Windows. The
>> worse thing is that it is with paths like
>> C:\Squid\auth\ncsa_auth.exe
>> or C:\Squid\redirect.exe but not mention anywere in config and/or
>>docs
>> How often '\n' and '\r' are used in config ?
>
> On windows you can use / instead of \. Not sure aboout OS/2.

"can use" is the source or bugs etc. No one exepts aliens and robots
 can take in mind what he/she can use and what can't

>
> On all using you can use \\ instead of \
It is the same thing, if it is not specially mension somewere at
first strings of docs

>
> And it is not a new change, strwordtok has behaved like this for as
>long as it existed (Sep 2002). The only new change is that it now
>(Aug 2004) decodes \n and \r into NL / CR instead of bare 'n' / 'r'.

as it was function with knowledge of quoting I used precise
  handling for "\\\\" and "\\\"" cases

        default:
          if(ch == '\\' && (p[1] == '\\' || p[1] == '\"'))
          { p++;
            *d++ = ch = *p;
            if (ch)
                p++;
          } else {
            if (!quoted && isspace(*p)) {
                p++;
                goto done;
            }
            *d++ = *p++;
          }
            break;

>
> The main reason why strwordtok is used when parsing helper paths etc
>is to allow for specifications of paths or arguments with spaces in
>them. In addition it may in some extreme cases be meaningful to be
>able to specify NL / CR characters in the argument strings to the
>helpers (but not in the path if the administrator has any sane
>mind..)
  
hmmmm.... there is greate rakes potential - if somebody make a
mistake in string with \n and \r and squid wil say "Hey, you have
an error in string %s" and output this string

SY,
Evgeny Kotsuba
Received on Tue Jan 25 2005 - 16:41:30 MST

This archive was generated by hypermail pre-2.1.9 : Tue Feb 01 2005 - 12:00:02 MST