• Resolved talgat

    (@talgat)


    Hello,

    I found some issues with form validation (plugin version is 2.6).

    1. There is no validation of required fields on the server side. There is only validation for a correct email. So, if JS is turned off a form will be successfully submitted.
    2. If email is not valid the error message is not displayed.

    Why it happens.
    The mistake you can find in class.widget.php

    For this type of error you return the string “Please enter a valid email address.” (line #352). As a result $response[$widgetid] has a type of string. Then you check a value this way $printresponse = ( self::$response[$widgetid][0] ) (line #276).
    But as mentioned above $response[$widgetid] contains the string not an array. And $response[$widgetid][0] returns the first letter of the string. In this case it’s “P”. So this condition always returns true and show a green message with the text “l” (the second letter of the real message).

    How to fix.
    First of all you should change the line #352.
    From
    return __( 'Please enter a valid email address.', 'benchmark-email-lite' );
    To
    return array( false, __( 'Please enter a valid email address.', 'benchmark-email-lite' ) );

    And secondly you should add a strict comparison in line #276.
    $printresponse = ( self::$response[$widgetid][0] === true )


    Regards,
    Talgat

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter talgat

    (@talgat)

    Hello,

    Another one error I see in logs.

    Invalid argument supplied for foreach() in ../benchmark-email-lite/lib/class.api.php on line 105.

    Invalid argument supplied for foreach() in ../benchmark-email-lite/lib/class.api.php on line 117.

    It looks like the lists() and signup_forms() functions return a string in some occasions. And you don’t check the returned value before to put it to the foreach.


    Regards,
    Talgat

    Plugin Author Sean Conklin

    (@seanconklin)

    Hi @talgat,

    Thank you for bringing these code issues to our attention. We have a Dev Edition current in QA getting ready for release in a few weeks and I will look into getting these items put into that release.

    Let us know if you come across anything else!

    Regards,
    Sean Conklin

    Plugin Author Sean Conklin

    (@seanconklin)

    Hi @talgat,

    We have merged in these fixes and you can take a sneak peek at our soon to be released v2.7 here: https://downloads.www.ads-software.com/plugin/benchmark-email-lite.zip

    Thanks again for contributing your findings!

    Regards,
    Sean Conklin

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘An issue with form validation’ is closed to new replies.