mrackley / StratusForms

Lightweight InfoPath alternative for SharePoint 2007,2010,2013,2016,2019 and Office 365
82 stars 36 forks source link

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

Open Matt15BRJ opened 2 years ago

Matt15BRJ commented 2 years ago

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.

mrhyde1st commented 2 years ago

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

Matt15BRJ commented 2 years ago

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.

mrhyde1st commented 2 years ago

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.