rtakehara / 5e-Framework

A comprehensive 5th Edition Dungeons & Dragons Framework for MapTool.
GNU Affero General Public License v3.0
52 stars 9 forks source link

+ signs lost when editing Pin GM Notes #51

Closed jshank closed 2 years ago

jshank commented 2 years ago

Describe the bug After saving edits to the GM Notes of a pin, any use of the + character is lost.

To Reproduce Steps to reproduce the behavior:

  1. Create a new pin
  2. Edit the GM notes as follows:

 - Check to see who, if anyone, is surprised. The party cannot surprise the goblins, but the goblins might surprise some or all the characters. Make a [Goblin Dexterity (Stealth) check](roll "1d20 6"), rolling once for all of them. Compare the result to the characters' passive Wisdom (Perception) scores **13**. Any character whose score is lower than the goblins' check result is surprised and loses his or her turn during the first round of combat.
    - Goblins stealth roll **[r:gob_stealth=1d20+6]: [r:if(gob_stealth > 13, "Goblins stay hidden", "Goblins are seen!!")]**
  1. Save the notes and see the macro work for a 1d20+6 roll
  2. Edit the GM Notes
  3. Make any change and hit Save
  4. Notice that the 1d20+6 is now 1d20 6
    - Goblins stealth roll **[r:gob_stealth=1d20 6]: [r:if(gob_stealth > 13, "Goblins stay hidden", "Goblins are seen!!")]**

Expected behavior + is maintained as part of the text

Screenshots N/A

Desktop (please complete the following information):

rtakehara commented 2 years ago

found the problem, in the "Lib:Character" token, the "Change Pin Form" macro is missing an encode in the note [h:description=encode(description)], adding it in line 11 after the getStrProp variables fixed it

jshank commented 2 years ago

We get to keep the + now but lose all the new line characters (replaced with %0A)

jshank commented 2 years ago

@rtakehara Can you reopen or should I create a new issue?

jshank commented 2 years ago

I think I fixed Lib:Character - Change Pin Form so that it doesn't wipe out the + and handles %0A correctly Add this on/after line 11: [h:description=encode(description)]

Replace line 40 with this

[h, if(decode(name)=="new"), CODE:{
[description=""]
};{
[description=decode(description)]
[description=replace(description, "%0A", decode("%0A"))]
}]

<textarea name="value" cols="60" rows="30">[r:description]</textarea>

Previously was <textarea name="value" cols="60" rows="30">[r:if(decode(name)=="new","",decode(description))]</textarea>

Tdue21 commented 2 years ago

Uhm... semi-colon has the same issue ... At least after adding this fix.

Tdue21 commented 2 years ago

I am confusion ... opened the pin again to get some screen shots, and now it works with semi-colon ?!

jshank commented 2 years ago

I found the same, I had to save the corrected data once to the GMNotes section and then it loaded correctly. Previously, the first load would "corrupt" the data and then you saved it as corrupted (missing : and/or +). Once the macro is updated, it won't corrupt the data the first time. My biggest lesson is that I keep all of the source for the pins in plain text .md files and copy the data into the pin. That way I always have a clean source.