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

First row in Grid encoding problem in textfields

Developer Preview

DigitalDoctors's avatar
DigitalDoctors
76 posts
12 years ago
DigitalDoctors's avatar DigitalDoctors

Hi team,

This bug may be fixed by the soltuion in this post.

In the grid field the first rows of textfields are having incorrect encoding applied (my guess is double encoding but I could be wrong).

You can reproduce this by having a grid field with two rows of two text fields and enter something that needs to be encoded like.

1'2"3

In all of the fields and then after submitting view the entry.

In case anyone wants to resolve this before the next dev preview you can comment out line 639 in system\codeigniter\system\helpers\form_helper.php.

Be fair warned though that I really do consider this a temporary hack and in no way a fix as it may have other adverse effects I am sure CI and EE clean the inputs thoroughly before databasing but still.

Thanks for your time guys.

       
Kevin Cupp's avatar
Kevin Cupp
791 posts
12 years ago
Kevin Cupp's avatar Kevin Cupp

Hi DigitalDoctors,

That’s actually a new bug, thanks for catching that! I think we’re unnecessarily form_prepping the data we send to fieldtypes when we call their display_field() method, that shouldn’t be happening, fieldtypes should handle that themselves. It’s basically just to escape quotes when using the data in a form attribute. This should fix your problem:

Open system/expressionengine/fieldtypes/grid/libraries/Grid_lib.php, search for this line:

$display_field = ee()->grid_parser->call('display_field', form_prep($row_data));

Then just remove the call to form_prep() like so:

$display_field = ee()->grid_parser->call('display_field', $row_data);

It should fix values you saved to the DB without saving their encoded selves to the DB thereafter. For example, if you saved 1’2”3 in a field but didn’t edit that entry again, it should be fine, but if you ended up saving a value with entities in it, it won’t fix those.

Thanks again! Kevin

       
DigitalDoctors's avatar
DigitalDoctors
76 posts
12 years ago
DigitalDoctors's avatar DigitalDoctors

Thanks Kevin,

I would tend to agree with you but I had came to this conclusion when looking for a fix and the result it has is.

The first row is encoded properly however every row after isn’t encoded properly so a text field value of 1’2”3 results in

<input type="text" value="1'2"3 />

Results in

1'2

Which of course cuts off after whatever the enclosing quotes are in this case the double quote.

Cheers

       
Kevin Cupp's avatar
Kevin Cupp
791 posts
12 years ago
Kevin Cupp's avatar Kevin Cupp

Thanks, DigitalDoctors. That’s another bug in CI’s form_prep method that we’ve been battling lately. It’s a little over-protection to make sure it doesn’t double-encode things and it causes issues like this. It’s on our radar and we’ll get a fix in.

       
Kevin Cupp's avatar
Kevin Cupp
791 posts
12 years ago
Kevin Cupp's avatar Kevin Cupp

Actually DigitalDoctors, this should be fixed in the latest dev preview build. Can you give it a try there and see if you still have the same problem? I looks like Wes and Pascal reworked form_prep() to make it work better.

       
DigitalDoctors's avatar
DigitalDoctors
76 posts
12 years ago
DigitalDoctors's avatar DigitalDoctors

Thanks Kevin,

I don’t have time right now but will update this post when I do.

Cheers

       

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.