On Wed, Sep 11, 2002 at 11:18:06AM +0200, Pavel Kankovsky wrote:
> On 5 Sep 2002, Michel Arboi wrote:
> 
> > "Pavel Kankovsky" <[EMAIL PROTECTED]> writes:
> > 
> > > It appears many existing NASL scripts use string() to concatenate strings.
> > 
> > c=a+b; works and should be used instead, right.
> 
> Not good enough:
> 
> a = "0";
> b = "1";
> display(a + b, "\n");
> 
> returns 1 not 01
> 
> Apparently, this is the only safe way to concatenate two strings
> of arbitrary binary data (unless I know both values are purified):
> 
>   r = "";
>   for (__i = 0; __i < strlen(a); __i = __i + 1)
>     r = string(__r, raw_string(ord(a[__i])));
>   for (__i = 0; __i < strlen(b); __i = __i + 1)
>     r = string(__r, raw_string(ord(b[__i])));

You can also explicitely purify the values using string() - 

        a = string("\\n");      # a equals to "\n"
        b = string("\\r");      # b equals to "\r"

        c = string(b,a);        # c equals to "\r\n" (and not
                                # carriage return)


-
[EMAIL PROTECTED]: general discussions about Nessus.
* To unsubscribe, send a mail to [EMAIL PROTECTED] with
"unsubscribe nessus" in the body.

Reply via email to