[mapserver-dev] classObj.setText, text must be quoted

Lime, Steve D (DNR) Steve.Lime at state.mn.us
Tue Feb 21 20:01:49 EST 2012

In 6.0 class->text is a true expressionObj, not a string as in previous versions so at least via SWIG setText() calls msLoadExpressionString(). I think there could be a bug in that function at line 2169 (in trunk). Older versions of that function treat the input string as a the expression if parsing doesn't detect a delimited type. So does this version but in a different way:

// trunk
    exp->type = MS_STRING;
    exp->string = msStrdup(msyystring_buffer);

// 5.6 branch
    exp->type = MS_STRING;
    if((strlen(value) - strlen(msyytext)) == 2)
      exp->string = strdup(msyytext); /* value was quoted */
      exp->string = strdup(value); /* use the whole value */

I've got a feeling this has to do with escaping quotes where msyystring_buffer contains the escaped text. Perhaps we could do something like:

    exp->type = MS_STRING;
    if(... if first char in value is not a single or double quote ...)
        exp->string = strdup(value);  /* use the whole value */
        exp->string = msStrdup(msyystring_buffer);

Alan, does this make sense or is there another way to know that escaping was processed?


From: mapserver-dev-bounces at lists.osgeo.org [mapserver-dev-bounces at lists.osgeo.org] on behalf of Tamas Szekeres [szekerest at gmail.com]
Sent: Tuesday, February 21, 2012 4:09 PM
To: mapserver-dev at lists.osgeo.org
Subject: [mapserver-dev] classObj.setText, text must be quoted

Hi Devs,

By using the following mapscript example:

     // creating a new map from scratch
      mapObj map = new mapObj(null);
      // adding a layer
      layerObj layer = new layerObj(map);
      // define the class
      classObj classobj = new classObj(layer);
 classobj.setText("Sample Text");
      Console.WriteLine("Sample Text -> " + classobj.getTextString());
 classobj.setText("Sample T");
      Console.WriteLine("Sample T -> " + classobj.getTextString());
 classobj.setText("\"Sample T\"");
      Console.WriteLine("\"Sample T\" -> " + classobj.getTextString());

I got the following output (from trunk):

Sample Text -> "Sample Text"
Sample T -> "Sample"
"Sample T" -> "Sample T"

6.0 branch produces this:

Sample Text -> "Sample"
Sample T -> "Sample"
"Sample T" -> "Sample T"

Do we have a requirement that the texts must be quoted which is passed to classobj.setText?

Best regards,


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-dev/attachments/20120222/7a422798/attachment.html

More information about the mapserver-dev mailing list