This may seem like a stupid question, but what is the goal of your script? Are you trying to sanitize user input to avoid SQL injection attacks? Because that’s what I thought the system.db.runPrepUpdate was supposed to do.
Is there a way to check how many varchars a column was set for in Ignition?
I might put just limit to 80 characters.
Comments come into a text field.
Submit button runs a script.
Gets the comment.
supposed to sanitize it…
then puts it into the runprepupdate
However, I was getting a ] on the end when I look at the logs for the error running the script.
So maybe too many characters were being used and the error just puts a ] there
I would use Regular Expressions for this, and condense the code significantly.
import re
Comments = self.parent.parent.getChild("topspacer flex_5").getChild("TextField_0").props.text
Comments = re.sub('[#/,]','_',re.sub('[\?!%\^\*~\[\]\{\}\+=`\\"$|]',' ',Comments))
Also, I would tend to not let them input a string longer than acceptable. As in rather than just accepting and then stripping the text, don’t allow them to enter any characters past that point.
The first leads the user to believe what they entered was successfully processed as they entered it rather than as it was actually processed.
I'm still somewhat confused why you have to escape these characters when properly using runPrepUpdate. When supplied as parameters do these cause a fault?
Can you post the error message you get when the characters are not escaped?
I have tried to answer those questions.
Probably there is a gap between my understanding and your expectation in an answer I think.
I am doing my best to read the content recommended and learn it.
Personally I think that sanitizing the user input in this fashion is counter productive.
Assuming a non-malicious actor, the user has explicitly entered a richly formatted comment, which the system then helpfully cleans up. Thus what is saved in the system is not what the user entered, and the user has no idea that the difference exists.
But because we should always assume a malicious actor, the system should be able to cope with any user entered data and not crash and burn due to a craftily formatted input. But IMHO filtering text is not the preferred way to do it. (See SQL Injection Prevention Cheat Sheet for example, where input filtering is the last of the suggested methods)
Thanks for the help, and sorry I didn’t see this question. The posts were rapid for me. I was also trying to researching things that were said and read recommended pages. sorry