[BUG B91] I think I found a really obscure parser bug

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
User avatar
aliasmask
RPTools Team
Posts: 9031
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

[BUG B91] I think I found a really obscure parser bug

Post by aliasmask »

The code:

Code: Select all

[H: A = 10]
[H, if(A == 0): B = ' ']
There are so many things you can do to make this work, but it boils down to the above combination. If you have an if roll option and you assign a variable to a string using single quotes and have   in there, it gives this error. If you change any one of those things, then it works. I can change the quotes to double quotes. I can removed the if statement or I can not include   in the string and it will work. I can also add the false part and have it work.

The original discovery came from this line in my code:

Code: Select all

[H, if(percent == 0): barHtml = strformat('<table width="200"><tr><td style="background-color:white"> </td></tr></table>')]
I think somehow, given this combo it's trying to treat the if roll option as the if function.
... Debugging ...

Code: Select all

2015-07-10 04:08:09,908 [client.MapToolLineParser:1301] DEBUG - A = 10
2015-07-10 04:08:09,911 [client.MapToolLineParser:1301] DEBUG - if(A == 0, 1, 0)
2015-07-10 04:08:09,913 [client.MapToolLineParser:1301] DEBUG - '
2015-07-10 04:08:09,914 [client.MapToolLineParser:1319] DEBUG - java.lang.NullPointerException
2015-07-10 04:08:09,916 [client.MapToolLineParser:1264] INFO - [H: A = 10]
[H, if(A == 0): B = ' ']
net.rptools.parser.ParserException: java.lang.NullPointerException error executing expression '.
	at net.rptools.maptool.client.MapToolLineParser.parseExpression(MapToolLineParser.java:1320)
	at net.rptools.maptool.client.MapToolLineParser.parseLine(MapToolLineParser.java:1155)
	at net.rptools.maptool.client.MapToolLineParser.parseLine(MapToolLineParser.java:630)
	at net.rptools.maptool.client.macro.MacroManager.executeMacro(MacroManager.java:214)
	at net.rptools.maptool.client.ui.commandpanel.CommandPanel.commitCommand(CommandPanel.java:495)
	at net.rptools.maptool.client.ui.commandpanel.CommandPanel.commitCommand(CommandPanel.java:434)
	at net.rptools.maptool.client.AppActions$34.execute(AppActions.java:1389)
	at net.rptools.maptool.client.AppActions$ClientAction.actionPerformed(AppActions.java:2802)
	at javax.swing.SwingUtilities.notifyAction(Unknown Source)
	at javax.swing.JComponent.processKeyBinding(Unknown Source)
	at javax.swing.JComponent.processKeyBindings(Unknown Source)
	at javax.swing.JComponent.processKeyEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
	at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
	at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
	at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
	at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.awt.EventQueue.access$200(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue$4.run(Unknown Source)
	at java.awt.EventQueue$4.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at net.rptools.maptool.client.swing.MapToolEventQueue.dispatchEvent(MapToolEventQueue.java:36)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
I tested this back to b86 and it gave an error as well. May be related to java 7/8 changes.

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: [BUG B91] I think I found a really obscure parser bug

Post by wolph42 »

I hope this is not related to my more than 2 levels of code exploit that I've employed now for the last couple of years. Cause that would mean that fixing this, would break A LOT: http://www.lmwcs.com/rptools/wiki/Worki ... ODE_levels

User avatar
aliasmask
RPTools Team
Posts: 9031
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: [BUG B91] I think I found a really obscure parser bug

Post by aliasmask »

BTW, this was also a bug in MOTE and this is what they said it was.
it's caused by the parser regex not being able to capture the last apostrophe when the entity is found in a string. it doesn't affect quotes, it seems.

fixed.

Post Reply

Return to “Macros”