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

Lime, Steve D (DNR) Steve.Lime at state.mn.us
Wed Feb 22 10:32:13 EST 2012


msyytext/msyystring isn’t being truncated per se it’s just that a string with spaces is not valid in a mapfile. That is:

  TEXT Sample Text

would normally generate a parsing error. In this case only the string Sample Text is being parsed and without the quotes only the text ahead of the space is matched. I suppose it’s possible to relax the string matching expression in maplexer.l when in EXPRESSION_STRING context to allow spaces and other characters.

Steve

From: Tamas Szekeres [mailto:szekerest at gmail.com]
Sent: Wednesday, February 22, 2012 9:14 AM
To: Lime, Steve D (DNR)
Cc: mapserver-dev at lists.osgeo.org
Subject: Re: [mapserver-dev] classObj.setText, text must be quoted

Checking the first character instead of the length would be a good solution for MapServer 6.0 and the earlier versions. But I'm not sure how this would solve the same problem in trunk. Actually when getSymbol is failing we can obtain only a truncated text from msyytext/msyystring so we cannot use this to assign the value to the corresponding property. We should probably find out the reason why  msyytext/msyystring is truncated in this case or use the "value" argument of loadExpressionString instead. Does this make sense?

Best regards,

Tamas


2012/2/22 Lime, Steve D (DNR) <Steve.Lime at state.mn.us<mailto:Steve.Lime at state.mn.us>>
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 */
    else
      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 */
    else
        exp->string = msStrdup(msyystring_buffer);

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

Steve
________________________________
From: mapserver-dev-bounces at lists.osgeo.org<mailto:mapserver-dev-bounces at lists.osgeo.org> [mapserver-dev-bounces at lists.osgeo.org<mailto:mapserver-dev-bounces at lists.osgeo.org>] on behalf of Tamas Szekeres [szekerest at gmail.com<mailto:szekerest at gmail.com>]
Sent: Tuesday, February 21, 2012 4:09 PM
To: mapserver-dev at lists.osgeo.org<mailto: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,

Tamas


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


More information about the mapserver-dev mailing list