Flavio,

Thank you, this works perfectly.

It could be easily added to ERXWOTextField and WOText element by default...

Is there any situation where control char would be desirable in a web text 
input (except for the tab and new line) ?

Samuel


> Le 13 sept. 2016 à 10:05, Flavio Donadio <[email protected]> a écrit :
> 
> 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 <[email protected]> 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      ([email protected])
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/webobjects-dev/flavio%40donadio.com.br
>> 
>> This email sent to [email protected]
> 


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

This email sent to [email protected]

Reply via email to