Removing Unwanted Characters From a Web Form Submission

Devin Asay devin_asay at byu.edu
Mon Nov 8 10:34:47 EST 2010


On Nov 8, 2010, at 6:00 AM, Gregory Lypny wrote:

> Hello everyone,
> 
> I'm building an On-Rev site, and one of the pages will be a form with a field that is intended for the submission of about a page of comments.  I want to gather the submissions and process them as an array in LiveCode with the contents of another form field as the key.  It would look something like
> 
> 	stringKey1 <itemDelimiter> longStringOfComments1
> 	stringKey2 <itemDelimiter> longStringOfComments2
> 	stringKey3 <itemDelimiter> longStringOfComments3
> 
> and so on.  I need to convert the comments to a string by removing line feeds and perhaps other characters that might cause problems.  Is removing Return and Tab enough?
> 
> 	replace return with space in longStringOfCommentsNum
> 	replace tab with space in longStringOfCommentsNum
> 
> Because it is coming down from a server, I'm not sure whether I should refer to other linefeed characters and what those are.

Gregory,

If you want to be sure of catching all line delimiting characters you could do this:

  replace (numToChar(13) & numToChar(10)) with space in tComments
  replace numToChar(13) with space in tComments
  replace numToChar(10) with space in tComments

As far as which other characters you should remove, have you considered just using urlEncode/urlDecode? It's not specifically intended for this situation, but I would think urlEncode would safely convert any problematic characters, then you could urlDecode the string before you display it again.

Regards,

Devin

Devin Asay
Humanities Technology and Research Support Center
Brigham Young University




More information about the use-livecode mailing list