• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Invisible and invalid char in textfield
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Invisible and invalid char in textfield


  • Subject: Re: Invisible and invalid char in textfield
  • From: Flavio Donadio <email@hidden>
  • Date: Tue, 13 Sep 2016 11:05:23 -0300

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@hidden> 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@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Invisible and invalid char in textfield
      • From: Samuel Pelletier <email@hidden>
References: 
 >Invisible and invalid char in textfield (From: Samuel Pelletier <email@hidden>)

  • Prev by Date: Example code from Apple?
  • Next by Date: Re: Invisible and invalid char in textfield
  • Previous by thread: Invisible and invalid char in textfield
  • Next by thread: Re: Invisible and invalid char in textfield
  • Index(es):
    • Date
    • Thread