BernhardPosselt / foundryvtt-special-dice-roller

A FoundryVTT module that supports rolling L5R, VtM 5e, Genesys and SWTTRP dice in chat
GNU Affero General Public License v3.0
13 stars 17 forks source link

Issue with Parser alphabet #9

Closed gizmo2342 closed 4 years ago

gizmo2342 commented 4 years ago

https://github.com/BernhardPosselt/foundryvtt-special-dice-roller/blob/ca0d05ee023f7419dd039d93e72ff09d9438ee02/src/parser.ts#L43-L65

While doing further testing of the HEXRoller, we stumbled upon an issue with the alphabet. HEXRoller uses "-" as one of the dice character, which causes problems with the RegExp you create in line 53, as it is treated as part of a character range. Other than moving it to the end of the alphabet, there is no real way to work around this issue, as escaping it in the HEXRoller's parser would then cause problems with the letters array created in line 54.

My recommendation would be to check the alphabet for a "-" (and other possibly problematic characters) and escape them before creating the RegExp.

BernhardPosselt commented 4 years ago

Yep, just tried that right now :)

Maybe replace the - and + with n for negative and p for positive. Can you create a pull request?