|
xekon Apprentice
Joined: 11 Oct 2007 Posts: 154
|
Posted: Sat May 02, 2009 9:06 am
[3.06 beta] Regular Expression Trigger using LUA Crashes client, Possible BUG |
Regex Trigger pattern:
Code: |
^\| Name\s+: (.*) \s+\|$ |
command in LUA code:
Code: |
if string.sub(tostring(zs.param(1)),1,6) == "table:" then
tempstring = string.gsub(string.gsub(table.concat(zs.param(1),"|"),'"','\"'),"^%s*(.-)%s*$", "%1")
else
tempstring = string.gsub(string.gsub(zs.param(1),'"','\"'),"^%s*(.-)%s*$", "%1")
end
print(tempstring) |
make that trigger then run these off the command line (You will see that all of these work):
Code: |
#show "| Name : >.: !Press! Hat :.< |"
#show "| Name : <]~Amazonian~v~Arrowhead~v~Necklace~[> |"
#show "| Name : -+MagicalEther+- |"
#show "| Name : \|/ Druid Kilt of [**> PK <**] Wrath \|/ |"
#show "| Name : FaetorAde ® |"
#show "| Name : . o O ===Bear Goggles=== Oo . |"
#show "| Name : (!(Sanctuary)!) |"
#show "| Name : ^*^Darane Svatura^*^ |"
#show "| Name : Trandorfir Pani ---'---,{@ |"
#show "| Name : a drink called, ""bloody heads"" |" |
Next run this off the command line (Crashes Cmud Client):
Code: |
#show "| Name : \""""""|SCARS OF BATTLE|""""""/ |" |
I know its possible that I just wrote my trigger incorrectly.... if that is all it is I would appreciate the help... but the manor in which the error popped up when the client crashed made me think that its probably a bug. |
|
Last edited by xekon on Sat May 02, 2009 8:18 pm; edited 1 time in total |
|
|
|
xekon Apprentice
Joined: 11 Oct 2007 Posts: 154
|
Posted: Sat May 02, 2009 9:18 am |
I have narrowed it down to when there is Quotes and a "|" in the same line....
I tried(works):
Code: |
#show "| Name : a drink called, ""bloody heads"" |" |
like(crashes):
Code: |
#show "| Name : a drink called, ""bloody| heads"" |" |
it seems like its when the | is between quotes because this works just fine.
Code: |
#show "| Name : a |drink called, ""bloody heads"" |" |
and it crashed..... not sure if this is something that can be fixed through my coding or not... because I do replacements on double quotes to escape them and I do the tabl.concat when its a table... and tables concat "|" just find when no quotes are present and quotes get escaped just fine when no table "|" is present |
|
Last edited by xekon on Sat May 02, 2009 8:18 pm; edited 1 time in total |
|
|
|
Dumas Enchanter
Joined: 11 Feb 2003 Posts: 511 Location: USA
|
Posted: Sat May 02, 2009 1:02 pm |
Can someone move this to the beta forum?
|
|
|
|
xekon Apprentice
Joined: 11 Oct 2007 Posts: 154
|
Posted: Sat May 02, 2009 1:05 pm |
The issue exists in non beta version as well... if that makes any difference.
|
|
|
|
Dumas Enchanter
Joined: 11 Feb 2003 Posts: 511 Location: USA
|
Posted: Sat May 02, 2009 2:03 pm |
hmm, I got the crash from this. But when I ran a syntax check on the trigger, I came up with an illegal token error on this line:
Code: |
tempstring = string.gsub(string.gsub(zs.param(1),'"','\"'),"^%s*(.-)%s*$", "%1") |
maybe something wrong there? I'm not sure since I'm not as familiar with Lua.
Though that doesn't make much sense as the first part of the if statement has all the same parts. |
|
|
|
xekon Apprentice
Joined: 11 Oct 2007 Posts: 154
|
Posted: Sat May 02, 2009 2:41 pm |
I don't believe it to be that line because i can comment it out and it still crashes.....
|
|
|
|
Dumas Enchanter
Joined: 11 Feb 2003 Posts: 511 Location: USA
|
Posted: Sat May 02, 2009 2:43 pm |
heh, maybe part of my problem is that I don't quite see what you are trying to accomplish here.
|
|
|
|
Dumas Enchanter
Joined: 11 Feb 2003 Posts: 511 Location: USA
|
Posted: Sat May 02, 2009 2:53 pm |
I just plugged:
Code: |
teststring = zs.param(1)
print(teststring) |
for the trigger code. The good test cases still work. The moment your bad one gets plugged in for it, crash. |
|
|
|
xekon Apprentice
Joined: 11 Oct 2007 Posts: 154
|
Posted: Sat May 02, 2009 3:24 pm |
just trying to capture the item name as a string and store it in my db... a large portion of my script is not posted simply because its not needed to reproduce the problem that i am having.
Thanks for trying to help though, I definitely appreciate all the help I can get with this. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sat May 02, 2009 4:17 pm |
The syntax check won't work for Lua, because it's a zScript syntax check.
|
|
|
|
Dumas Enchanter
Joined: 11 Feb 2003 Posts: 511 Location: USA
|
Posted: Sat May 02, 2009 7:10 pm |
Yeah, but still there is either an issue with assigning zs.param(1) to a variable or with the print function. Unless even my modest test isn't correct syntax.
|
|
|
|
wrym Magician
Joined: 06 Jul 2007 Posts: 349 Location: The big palace, My own lil world
|
Posted: Sun May 03, 2009 3:27 am |
Wow, that's a HARD crash... but I think your making some of the code harder than it needs to be.
If I modify your code to
Code: |
<trigger priority="10" regex="true" language="Lua" id="1">
<pattern>^\| Name\s+: (.*) \s+\|$</pattern>
<value>if type(zs.param(1)) == "table" then
tempstring = string.gsub(table.concat(zs.param(1),"|"),'"','\"')
else
tempstring = string.gsub(zs.param(1),'"','\"')
end
print(tempstring)
</value>
</trigger>
|
Cmud no longer hard crashes on me, but still doesn't work.
Semi-obvious solution A, gsub " to a different character.
Not exactly perfect, but easy and lazy, and shouldn't give you any problems. |
|
_________________ "To the engineer, all matter in the universe can be placed into one of two categories: (1) things that need to be fixed, and (2) things that will need to be fixed after you've had a few minutes to play with them" - Scott Adams, The Dilbert Principle |
|
|
|
|
|