WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Apostrophes or Single Quote support in user registration email address

[Resolved] Apostrophes or Single Quote support in user registration email address

  • For a user email field, if the email address contain apostrophes or single quote (example abc’cd@abc.com), then you will get error per below while submit the form.

    ERROR: The email address isn’t correct.

    This is due to formatting.php is_email() validation checking not allow the email address with single quote ‘ to pass through when do email address checking. I am using wordpress version 3.0.5

    After some digging, I manage to make it work, and to share the workaround.
    1. Go to your wordpress folder and open file \wordpress\wp-includes\formatting.php
    2. Search for is_email keyword, or faster way search for “function is_email” without the quote.
    3. Look at comment // LOCAL PART Test for invalid characters. Example of the code per below:

    // LOCAL PART
    	// Test for invalid characters
    	if ( !preg_match( '/^[a-zA-Z0-9!#$%&\'*+\/=?^_

    {|}~\.-]+$/’, $local ) ) {
    return apply_filters( ‘is_email’, false, $email, ‘local_invalid_chars’ );
    }`

    4. Copy paste code below to replace above piece of code:

    // LOCAL PART
    	// Test for invalid characters
    	if ( preg_match( '/[!#$%&*+\/=?^

    {|}~]/’, $local ) ) {
    return apply_filters( ‘is_email’, false, $email, ‘local_invalid_chars’ );
    }`

    5. Basically it change the way the regular expression work to check for invalid character. Save the file and it should be working fine with user email address with ‘.

    If any problem, please do help me to fix ya.. πŸ™‚
    If the solution work, do let me know too…. I not done through intensive testing, so take your own risk.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Recopy the example code here… as the backticks code make it appear weird.

    // LOCAL PART
    // Test for invalid characters
    if ( preg_match( ‘/[!#$%&*+\/=?^`{|}~]/’, $local ) ) {
    return apply_filters( ‘is_email’, false, $email, ‘local_invalid_chars’ );
    }

    This works great for me.

    Why cant we have this added to the core / or at least built as a plugin so its not overwritten on each upgrade ?

    Thanks mobot123 πŸ™‚

    swinhoe,
    I have the same thought, wordpress.org team should be aware of this. Just they not fixing it. Anyway, glad to hear the solution work for you.

    swinhoe

    @swinhoe

    Im trying to write a plugin to fix this in the meantime –

    I have had a look about for an existing one, but without luck.

    Before I continue, have you built a Plugin on this subject before ?

    thanks

    berseck

    @berseck

    Wanna know a good reason for not doing that??

    Simple… the user won’t be able to login using his email if you want to… because it will save with a escape on the database and you won’t be ever able to check if that is valid or not…

    And for updates in future you shouldn’t change the wordpress core files…

    swinhoe

    @swinhoe

    Thats why im writing it as a plugin…

    The email does not appear with the escape in the DB and is still useable – does this mean it should be ok so long as the core is not amended ?

    mobot123

    @mobot123

    I never wrote a plugin before. It will be good if solution for this problem got solve in a plugin.

    swinhoe

    @swinhoe

    Good advice here – but I still cant get it to work as it should.

    http://wordpress.org/support/topic/writing-a-plugin-to-amend-the-core-possible?replies=7#post-2339585

    I opened a ticket in Trac to address this – im now weighing up if its worth writing the plugin before it gets ptched.. ?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Resolved] Apostrophes or Single Quote support in user registration email address’ is closed to new replies.