Can't input API Key - Character Limit on input box clips API Key value

Can't input API Key - Character Limit on input box clips API Key value

Okay this one's a shocker.

In the first step of setting up the ChimpExpress plugin on a new installation of WordPress 4.1:
I'm asked for my MailChimp API Key.

So I:

1. Sign into MailChimp, create an API Key, copy the API Key, paste it into the API Key text input box.
2. Click "Update Settings".
3. Receive Error Message: "Invalid MailChimp API Key: [x] (error code: 104)"
    [x] = 32 characters of my API Key
4. Note that my API Key is having the last character clipped off.
5. Check the API Key in Mail Chimp to find that it has 37 characters.
6. Open Developer Tools and inspect the API Key text input field, and see maxlength="36".
7. Edit the text input field text within the Developer Tools in Chrome to set maxlength="37".
8. Paste the API Key in again.
9. Click "Update Settings".
10. Watch in amazement as the form submits successfully and connects to my MailChimp account....


PLEASE FIX by removing unnecessary maxlength parameter!

Administrator has disabled public posting. Please login or register in order to proceed.

Re: Can't input API Key - Character Limit on input box clips API Key value

PSDtoFinal wrote:


5. Check the API Key in Mail Chimp to find that it has 37 characters.
...
7. Edit the text input field text within the Developer Tools in Chrome to set maxlength="37".

Thanks for finding this solution.

Actually, the datacenter identifier that follows after the hyphen is composed of a country identifier and counter.  The current code assumes the counter to stay below 10, but MailChimp has more than 10; e.g., 'us11'.  The counter could even exceed 100 in the future.

Is there a public development repository (e.g. github) for this plugin?

Code:


diff --git a/chimpexpress.php b/chimpexpress.php
index 2d5561a..b65af91 100644
--- a/chimpexpress.php
+++ b/chimpexpress.php
@@ -829,7 +829,7 @@ class chimpexpress
                 </label>
             </th>
             <td>
-                <input type="text" name="<?php echo $this->_optionsName; ?>[apikey]" style="text-align:center;width:270px;" maxlength="36" value="<?php echo esc_attr($this->_settings['apikey']); ?>" id="<?php echo $this->_optionsName; ?>_apikey" class="regular-text code" />
+                <input type="text" name="<?php echo $this->_optionsName; ?>[apikey]" style="text-align:center;width:270px;" maxlength="38" value="<?php echo esc_attr($this->_settings['apikey']); ?>" id="<?php echo $this->_optionsName; ?>_apikey" class="regular-text code" />
                 <?php /* if ( empty($this->_settings['apikey']) ) {
                 ?>
                 <input type="submit" name="get-apikey" value="<?php _e('Get API Key', 'chimpexpress'); ?>" />

Administrator has disabled public posting. Please login or register in order to proceed.