We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

EE2.x: Disallowed Key Character in module

Development and Programming

airways's avatar
airways
154 posts
15 years ago
airways's avatar airways

I have a module written for EE 2.0 which is based on the old Fresh Variables module. It saves a set of key / value pairs to be used in templates and elsewhere.

The module’s MCP form has fields like this:

echo form_input(array('name' => 'var_name[]', 'value' => $val['var_name'], 
    'maxlength' => 75, 'size' => 10, 'style' => 'width:90%'));
echo form_textarea(array('name' => 'var_value[]', 'value' => $val['var_value'], 
    'rows' => 4, 'cols' => 25, 'style' => 'width:90%'));

These field names are being blocked by the Input class with the familiar message “Disallowed Key Characters.”

This can be fixed by modifying this line:

In manager/codeigniter/system/core/Input.php change line 536 to:

if ( ! preg_match("/^[a-z0-9:_\/-\[\]]+$/i", $str))

So my questions are:

1) is this really the intended behavior? This seems to be very odd behavior according to what I know of the HTTP spec.

and

2) is there a different way to get post arrays to work?

Moved to Development and Programming by Moderator

       
John Henry Donovan's avatar
John Henry Donovan
12,339 posts
15 years ago
John Henry Donovan's avatar John Henry Donovan

airways,

What are the names of these fields?

In your second array you have repeated var_value[] for name as opposed to var_name[]

echo form_textarea(array('name' => 'var_value[]', 'value' => $val['var_value'], 
    'rows' => 4, 'cols' => 25, 'style' => 'width:90%'));
       
airways's avatar
airways
154 posts
15 years ago
airways's avatar airways

This code appears in a table. The fields are named var_name[] and var_value[]. Every time a row is added, a new occurrence of each field is added.

My original code is representative because showing the table code doesn’t have much to do with what’s going on. Here’s some output code:



This is perfectly valid HTML, and you guys wrote it anyway, so it’s odd that it doesn’t work now.

       
airways's avatar
airways
154 posts
15 years ago
airways's avatar airways

Figured it’d be easier to debug if I give you the updated code to take a look at. Here’s the module code.

       
airways's avatar
airways
154 posts
15 years ago
airways's avatar airways

The thing that really gets me is I don’t think CI blocks form arrays, but it also appears to have the same pattern I found in this Input class. I’m completely baffled.

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
15 years ago
Sue Crocker's avatar Sue Crocker

Hi, airways. We normally don’t answer these kinds of questions in this forum. Moving for additional community support.

       
airways's avatar
airways
154 posts
15 years ago
airways's avatar airways

So this now becoming even more of an issue. Going to a URL like this:

http://dev.local/~iraway/TEEL/teel/manager/index.php?S=c9b9d67cb9cf099283fd1a478b69fc576667bf41&D=cp&index;.php?S=c9b9d67cb9cf099283fd1a478b69fc576667bf41&D=cp&C=addons_modules&M=show_module_cp&module=fresha&method=save_variables

I get this error:

index_php?S
Disallowed Key Characters.

The value before the error is the “key” that the script is complaining about. How is the index file being interpreted as a key?

       
airways's avatar
airways
154 posts
15 years ago
airways's avatar airways

Doh the index.php?S part is in there twice, generating the URL incorrectly.

Still… this one aside, there’s a significant issue here. How can any module’s CP code post an array of values if CI_Input is blocking the [] characters?

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.