Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Escaping in getColumnContent (GridFieldDataColumns)
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  13 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jakob Kristoferitsch  
View profile   Translate to Translated (View Original)
 More options Jul 11 2012, 1:31 pm
From: Jakob Kristoferitsch <ja...@kristoferitsch.name>
Date: Wed, 11 Jul 2012 19:31:14 +0200
Local: Wed, Jul 11 2012 1:31 pm
Subject: Escaping in getColumnContent (GridFieldDataColumns)
Hi,
GridFieldDataColumns->getColumn content is currently broken. After
getting the value for a column either from getDataFieldValue or from a
callback method, it is imidiately escaped (see
<https://github.com/silverstripe/sapphire/blob/master/forms/gridfield/...>
lines 129 and 133).

This breaks the calls to castValue() and formatValue() immediately
below. It is also the root cause of
<http://open.silverstripe.org/ticket/7581> and
<http://open.silverstripe.org/ticket/7590>.

I guess the idea behind this escaping (added as a part of the redesign
in
<https://github.com/silverstripe/sapphire/commit/70d5ffefdd12eb3e69f40...>)
was to prevent XSS problems, but I think it is not feasible to just pass
all data through raw2xml, and especially not at this very early stage.

One good example are images, where the grid field should contain an img
tag for the thumbnail. In my opinion, it would be important that
$summary_fields can contain definitions like MyImage.CMSTHumbnail or
MyTextField.FirstSentence.

What are your thoughts about this? Where should the escaping happen? How
should the code know what not to escape?

Yours
Jakob


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Uncle Cheese  
View profile   Translate to Translated (View Original)
 More options Jul 11 2012, 8:34 pm
From: Uncle Cheese <aaroncarl...@gmail.com>
Date: Wed, 11 Jul 2012 17:34:05 -0700 (PDT)
Local: Wed, Jul 11 2012 8:34 pm
Subject: Escaping in getColumnContent (GridFieldDataColumns)

Yes! I was just going to post the same question!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
UndefinedOffset  
View profile  
 More options Jul 12 2012, 11:37 am
From: UndefinedOffset <edchip...@gmail.com>
Date: Thu, 12 Jul 2012 08:37:20 -0700 (PDT)
Local: Thurs, Jul 12 2012 11:37 am
Subject: Re: Escaping in getColumnContent (GridFieldDataColumns)

Ya i kinda miss the betas for that, it was so cool to be able to just add a
column Image.CMSThumbnail for example and it would render the image :(.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
dospuntocero  
View profile  
 More options Jul 13 2012, 12:15 pm
From: dospuntocero <francisco.are...@gmail.com>
Date: Fri, 13 Jul 2012 09:15:49 -0700 (PDT)
Local: Fri, Jul 13 2012 12:15 pm
Subject: Re: Escaping in getColumnContent (GridFieldDataColumns)

i was bugging the core team the other day about this same matter. lets hope
they found a solution soon :)

El miércoles, 11 de julio de 2012 13:31:14 UTC-4, Jakob Kristoferitsch
escribió:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jakob Kristoferitsch  
View profile  
 More options Jul 25 2012, 3:42 am
From: Jakob Kristoferitsch <ja...@kristoferitsch.name>
Date: Wed, 25 Jul 2012 09:42:23 +0200
Local: Wed, Jul 25 2012 3:42 am
Subject: Re: [silverstripe-dev] Escaping in getColumnContent (GridFieldDataColumns)
Hi,
I think #7590 (Image thumbnails broken in gridfield) is a problem that
should be fixed in 3.0.1, but it has just been delayed to 3.0.2. The fix
is easy, the hard part are the following decisions:

1. At what point should escaping happen?
2. Which code paths should be allowed to bypass escaping?
3. Should it be possible to opt out of escaping? How?

I propose a simple solution, see
<https://github.com/jakr/sapphire/commits/trac7590>. The big downside of
that solution is that the only way to bypass escaping is to return an
Object with a forTemplate method. This breaks the example in
setFieldFormatting (creating an anchor tag) and makes it impossible to
use a callback function returning a string that should not be escaped.

There are ways to work around that downside, but in my opinion the
decisions outlined above have to be made first. I am looking forward to
input on that point.

I have to say that I am disappointed that this thread has not sparked
any discussion so far. It is two weeks old, and the problem is highly
visible to anyone who actually tries to use GridField.

TL;DR: The bullet points need to be decided. What's your opinion?

Yours
Jakob

P.S.: As a reminder, the original post is below.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
edchip...@gmail.com  
View profile  
 More options Jul 25 2012, 8:11 am
From: edchip...@gmail.com
Date: Wed, 25 Jul 2012 12:11:11 +0000
Local: Wed, Jul 25 2012 8:11 am
Subject: Re: Re: [silverstripe-dev] Escaping in getColumnContent (GridFieldDataColumns)

I would have to agree Jakob, it is kind of one of those big not show  
stopper issues. Kinda disappointed to see it pushed to 3.0.2, seems like  
one of those things that could be slipped in before the final of 3.0.1.  
Especially since your fix Jakob seems to be working well and is a good  
solid fix.
On , Jakob Kristoferitsch <ja...@kristoferitsch.name> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sigurd Magnusson  
View profile  
 More options Jul 25 2012, 8:14 am
From: Sigurd Magnusson <sig...@silverstripe.com>
Date: Thu, 26 Jul 2012 00:14:44 +1200
Local: Wed, Jul 25 2012 8:14 am
Subject: Re: Re: [silverstripe-dev] Escaping in getColumnContent (GridFieldDataColumns)

Sorry guys as Hamish points out on the ticket comment there wasn't time -
hopefully you'll agree there's been a lot of activity for 3.0.1 - look at
the length of the change log - and the work on the 3.0.x line will continue
to be high for a while...

http://doc.silverstripe.org/framework/en/3.0/changelogs/rc/3.0.1-rc1

Cheers,
Sigurd.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
UndefinedOffset  
View profile  
 More options Jul 25 2012, 8:18 am
From: UndefinedOffset <edchip...@gmail.com>
Date: Wed, 25 Jul 2012 05:18:02 -0700 (PDT)
Local: Wed, Jul 25 2012 8:18 am
Subject: Re: Re: [silverstripe-dev] Escaping in getColumnContent (GridFieldDataColumns)

Ya makes complete sense to me, its just unfortunate. Oh well hopefully
3.0.2 will be just around the corner like 3.0.1 was :)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sigurd Magnusson  
View profile  
 More options Jul 25 2012, 9:01 am
From: Sigurd Magnusson <sig...@silverstripe.com>
Date: Thu, 26 Jul 2012 01:01:39 +1200
Local: Wed, Jul 25 2012 9:01 am
Subject: Re: Re: [silverstripe-dev] Escaping in getColumnContent (GridFieldDataColumns)

Yup - and keep sending in those bug reports and/or pull requests ;)

Sig

On 26 July 2012 00:18, UndefinedOffset <edchip...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jakob Kristoferitsch  
View profile   Translate to Translated (View Original)
 More options Jul 25 2012, 9:19 am
From: Jakob Kristoferitsch <ja...@kristoferitsch.name>
Date: Wed, 25 Jul 2012 15:19:25 +0200
Local: Wed, Jul 25 2012 9:19 am
Subject: Re: [silverstripe-dev] Escaping in getColumnContent (GridFieldDataColumns)
Sigurd Magnusson wrote:

 > Sorry guys as Hamish points out on the ticket comment there
 > wasn't time [...]

I accept that it's not part of 3.0.1 (thanks to Hamish for the detailed
explanation), my next goal is to get it into 3.0(.2) as soon as possible.

To do that, I would really like to start a discussion about where
escaping should happen and what code paths should be allowed to bypass it.

Unfortunately, this seems to be a bug where everyone agrees that it is
important, but nobody wants to make any decisions ;-). My proposed fix
is publicly available and I have explained the advantages and
disadvantages that I see. I now would like to get feedback on my
proposal as well as alternative ones.

I think the problem of where to escape applies to a lot of different
places, which is why I want to have the discussion about it in public.
I am actually quite fond of my approach - it might not be the best fit
in this situation, but I think the general direction is correct: Escape
everything, except for objects that promise to do that themselves (by
providing forTemplate(), XML() or something like that).

The dogmatic approach would be to provide an object that wraps a string,
knows what needs to be escaped and provides the methods needed to escape
it for XML output (as well as DB and any other output). The framework
would then never directly output strings, instead relying on these
wrapper objects.

Yours
Jakob


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andrew Short  
View profile  
 More options Jul 25 2012, 9:31 am
From: Andrew Short <andrewjsh...@gmail.com>
Date: Wed, 25 Jul 2012 23:31:03 +1000
Local: Wed, Jul 25 2012 9:31 am
Subject: Re: [silverstripe-dev] Escaping in getColumnContent (GridFieldDataColumns)

I would expect it to operate in the same way as the rest of the framework
escaping - by default escape strings but not objects. Then allow the user
to use the setFieldCasting method on GridFieldDataColumns to specify if a
string should not be escaped:

$columns->setFieldCasting(array('UnescapedField' => 'HTMLText'));

Andrew Short.

On Wed, Jul 25, 2012 at 11:19 PM, Jakob Kristoferitsch <


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jakob Kristoferitsch  
View profile   Translate to Translated (View Original)
 More options Jul 25 2012, 10:13 am
From: Jakob Kristoferitsch <ja...@kristoferitsch.name>
Date: Wed, 25 Jul 2012 16:13:49 +0200
Local: Wed, Jul 25 2012 10:13 am
Subject: Re: [silverstripe-dev] Escaping in getColumnContent (GridFieldDataColumns)
Andrew Short wrote:

 > I would expect it to operate in the same way as the rest of the
 > framework escaping - by default escape strings but not objects.

Ok, that goes in the direction I am implementing. I still think it is
best to call forTemplate on the Object at the end, since I read the
comment to getColumnContent to mean that the return value will be
directly inserted in the output:
 > @return string HTML for the column. Return NULL to skip.

 > Then allow the user to use the setFieldCasting method
 > on GridFieldDataColumns to specify if a string
 > should not be escaped:
 >
 > $columns->setFieldCasting(array('UnescapedField' => 'HTMLText'))

That is a nice way to handle this problem, but to enable that kind of
behavior I think that the call to castValue() should then be after the
call to formatValue (maybe even the last one). This would make it
possible to use the example from setFieldFormatting:
 > "myFieldName" => '<a href=\"custom-admin/$ID\">$ID</a>'
In combination with setFieldCasting this would then output the link
without escaping it.

Should I rearrange these calls or is there a reason for the current
order (I guess there is...)?

Thanks for your input,
Jakob
Am 25.07.2012 15:31, schrieb


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "[Fixed] Escaping in getColumnContent (GridFieldDataColumns)" by Jakob Kristoferitsch
Jakob Kristoferitsch  
View profile  
 More options Jul 31 2012, 4:18 pm
From: Jakob Kristoferitsch <ja...@kristoferitsch.name>
Date: Tue, 31 Jul 2012 22:18:30 +0200
Local: Tues, Jul 31 2012 4:18 pm
Subject: Re: [silverstripe-dev] [Fixed] Escaping in getColumnContent (GridFieldDataColumns)
Hi,
just to finish this thread: The issue has been fixed in 3.0.1

Yours,
Jakob


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »