StratusForms icon indicating copy to clipboard operation
StratusForms copied to clipboard

Line 671 in stratus-forms-1.55.js causes backslashes to continuously double

Open Matt15BRJ opened this issue 3 years ago • 3 comments

I was having a problem with my data bloating to huge sizes because everywhere there was a backslash in the json (i.e. all the people pickers and anywhere people used one in a textbox/area) they would double every time the form saved or reloaded. I found the culprit in line 671 of stratus-forms-155.js: value = value.replace(/\/g, "\\"); why is that there? I can't figure out what it is for. commenting it out fixed the problem I was having.

Matt15BRJ avatar Feb 07 '22 23:02 Matt15BRJ

That kind of thing is to stop people breaking the system as it stops the system treating the text as a potential escape code.

mrhyde1st avatar Feb 09 '22 07:02 mrhyde1st

But it has led to the system breaking for 'not enough memory' reasons as the forms have ballooned to over 35MB from the backslashes doubling every time a form gets saved or reloaded.

Matt15BRJ avatar Feb 09 '22 16:02 Matt15BRJ

Ok, I believe the fix...change the expression to

value=value.replace(/(\\|\)/gm,"\\");

this should leave escaped \ already untouched, and escape singular ones, though it gets a little complicated if there are more than 1 \ in a row.

Note when this posted it treated the \ as escaped, so I had to double all \ when adding. Not sure how that will affect any copying.

mrhyde1st avatar Mar 22 '22 21:03 mrhyde1st