Re: [Plugins-writers] Weird behavior with substr

From: Michel Arboi (mikhail@private)
Date: Sat Oct 08 2005 - 15:30:41 PDT

On Thu Oct 06 2005 at 19:29, Jon Passki wrote:

> I'm noticing weird behavior with substr and am wondering if this is
> excepted behavior. 

Yes, this is expected, although I admit it is rather suprising.

The problem comes from display(), which calls string() before printing a
"STRING2" / CONST_STR (string between double quotes) and does not for
a "STRING1" / CONST_DATA (strings between simple quotes)
[becauseof backward compatibility]

substr() always returns a "STRING1" / CONST_DATA, whatever its
argument type is.
And + returns a STRING1 if one of its arguments is a STRING1

> newst = substr(stuff,0);

Here, you converted stuff from "nessus" to 'nessus'

> ("c: " + c + "\n");

This is equivalent to :
"c:" + 'nessus' + "\n" = 'c:' + 'nessus' + '\\n'

> So, am I missing something 

Before you do string manipulation, make sure that you called string()
where needed.
Plugins-writers mailing list

This archive was generated by hypermail 2.1.3 : Sat Oct 08 2005 - 15:31:02 PDT