Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Zhiroc
Adept


Joined: 04 Feb 2005
Posts: 246

PostPosted: Thu Jul 31, 2008 4:35 pm   

[2.34] Unbalanced quotes in stringlist can corrupt it
 
In a new blank session:

1. Open the PE
2. Create a new package (I called it "test")
3. Create a variable, set it to type stringlist
4. Enter:
a
b"
c"
5. The stringlist will display correctly in the PE
6. Click on the Refresh, the 2nd and 3rd items get combined into one element b"|c"

Next example:
1. Do
Code:
tmp=a
#additem tmp {b"}
#additem tmp {c"}

2. In the PE, you will see that the 3 elements are preserved as individual items
3. Save the package
4. Remove the package from the session.
5. Open the package
6. In the PE, the 2nd and 3rd items get combined into one element b"|c"

Since stringlists are often the result of trigger captures, it is hard to say, "don't do this". For example, I have a trigger that captures MUSH poses into a "last 10" stringlist. Sometimes players forget a quote, and things like this can happen.

I notice that the XML representation of this variable is: <var name="tmp" type="StringList" id="1">a|b"|c"</var>

Rather than doing fancy quoting, I would simply use the power of xml (presuming that's how it's stored in the pkg file). For example:
Code:
<var name="tmp" type="StringList" id="1">
  <element>a</element>
  <element>b"</element>
  <element>c"</element>
</var>

Of course, this doesn't solve why the first case happens in the PE.

Similarly for a DB record, I would do: <element><key>xxx</key><value>yyy</value></element>
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Thu Jul 31, 2008 4:49 pm   
 
Quote:
Of course, this doesn't solve why the first case happens in the PE.

Exactly. The problem is that for backwards compatibility there must be a way to convert a string list to the a|b|c format, and a way to convert database variables to the key1=value1|key2=value2... format.

CMUD tries to detect embedded quotes and | characters and properly quote the values, but it looks like there is still a bug. In your example above, it was supposed to convert it to

a|"b"""|"c"""

but it seems to have gotten confused along the way. zMUD was *much* worse with this kind of stuff btw, and couldn't handle nested | characters either. CMUD handles most cases, but this seems to have slipped by in the testing.

I'll add your procedure to my test list and bug list and try to get it fixed soon. I definitely understand that this needs to be handled correctly.

Your XML idea is interesting and something that I'll consider. It doesn't change the fact that the bug needs to be fixed, but it might make string lists and database variables a bit more readable in the XML output.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net