Samuel,

The user might have copied from another app and pasted into the field.

The solution is to strip control characters from the user input. As you may 
know, there are a lot of ways to do that and dependent on the use case. For 
example, if it’s a multiline text input control (textarea), you may want to 
keep certain characters like carriage returns, line feeds and tabs.

One example of stripping all control characters using pure Java:

        String.replaceAll("\\p{Cntrl}", "”);

… and one example of stripping every control character, except for CR, LF and 
TAB:

        String.replaceAll("[\\p{Cntrl}^\r\n\t]+", "");

I am sure NSString has methods for that...


Cheers,
Flavio

> On 13/09/2016, at 09:40, Samuel Pelletier <sam...@samkar.com> wrote:
> 
> Hi,
> 
> I just encountered a strange error where a user managed to put a DEL char 
> inside a text field. This char raise an SQL Exception in the server.
> 
> First, I really would like to know how they manage to do this ! I do not even 
> know how to put a DEL (code 127) inside text with the keyboard. I had some 
> case with other control char in the past too.
> 
> Second, is there a wonder way to filter these or a Javascript method to 
> prevent them from the source, or any suggestion to handle this ?
> 
> Real users are alway a source of unpredicted challenges. 
> 
> Thank,
> 
> Samuel
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/webobjects-dev/flavio%40donadio.com.br
> 
> This email sent to fla...@donadio.com.br


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to