Orkut is escaping most person fields, and if they didn't then most of
the gadgets out there would render script tags verbatim. I haven't
seen a single gadget that treats a username as untrusted data.
On Tue, Apr 22, 2008 at 8:57 AM, Reinoud Elhorst <rei...@hyves.nl> wrote:
I think adding a new parallel method is sorta ugly. Could we instead add a param to the original method that says whether or not to escape the data? (And by default it would be true?)
so...
opensocial.DataRequest.prototype.newFetchPersonAppDataRequest = function(idSpec,
keys, opt_params) {}
plus a new enum...
opensocial.DataRequest.DataRequestFields = {
/**
* A boolean specifying whether or not to automatically
* escape all of the data returned. Defaults to true.
*
* @member opensocial.DataRequest.PeopleRequestFields
*/
ESCAPE_VALUES : 'escapeValues',
}
- Cassie
btw - I'm gathering that nobody cares that all activity and people fields are auto escaped?
On Fri, Apr 25, 2008 at 3:14 PM, Cassie <do...@google.com> wrote:I think adding a new parallel method is sorta ugly. Could we instead add a param to the original method that says whether or not to escape the data? (And by default it would be true?)
so...
opensocial.DataRequest.prototype.newFetchPersonAppDataRequest = function(idSpec,
keys, opt_params) {}
plus a new enum...
opensocial.DataRequest.DataRequestFields = {
/**
* A boolean specifying whether or not to automatically
* escape all of the data returned. Defaults to true.
*
* @member opensocial.DataRequest.PeopleRequestFields
*/
ESCAPE_VALUES : 'escapeValues',
}
- Cassie
btw - I'm gathering that nobody cares that all activity and people fields are auto escaped?
Are you saying that all people and activity fields are auto-escaped according to the spec? I searched for this, but couldn't find it, so I assumed it was an implementation irregularity (and I would be against it for the very same reasons )
I'm fine with any solution that does escaping by default (to handle
ignorance) and provides an option to unescape (to handle people with
legitimate needs for unescaping.)
I like Cassie's proposal to add paramers to
newFetchPersonAppDataRequest. I'd lean towards an enumeration rather
than a boolean value. Maybe the following possibilities?
ESCAPE_VALUES: 'htmlEscape', // default value
ESCAPE_TYPE: 'none', // use this if you want to enable XSS worms to
attack your users.
Then we can add more types later as needed.
I should comment, however, that if you call
gadgets.util.unescapeString() on untrusted data today and then assign
that data to innerHTML, your app is vulnerable. I've yet to see an
opensocial app that does anything except assign data to innerHTML, so
I'm pretty sure that anybody who uses ESCAPE_TYPE = none is asking for
trouble.
I should comment, however, that if you callgadgets.util.unescapeString() on untrusted data today and then assign
that data to innerHTML, your app is vulnerable. I've yet to see an
opensocial app that does anything except assign data to innerHTML, so
I'm pretty sure that anybody who uses ESCAPE_TYPE = none is asking for
trouble.
If the end result of this is:
1) JSON is handled in such a way that developers don't need to call
unescape to deal with it.
2) The API gets a new enumerated type describing how the developer
wants the returned data formatted.
3) The default handling is HTML escaping.
... then that's +1 from me.
OK, so we're talking about two modifications to the same API in
parallel in different threads. Classy. =)
+1
> 2) The API gets a new enumerated type describing how the developer
> wants the returned data formatted.
+1 -- though I'd much prefer to have a new function to retrieve raw
data (i.e. getRawField) because I have a hard time swallowing the
verbosity of "opensocial.DataRequest.DataRequestFields.RAW_VALUE".
> 3) The default handling is HTML escaping.
+1
I think I'm the one who suggested an enumerated type originally, but
I'm fairly neutral as to the specifics of function name vs parameter.
On Tue, Apr 29, 2008 at 2:53 PM, Brian Eaton <bea...@google.com> wrote:
OK, so we're talking about two modifications to the same API in
parallel in different threads. Classy. =)
Yeah, but Cassie is the mutex, so it's OK ;)
I'm confused. If we're encouraging the use of plain strings, what is
the point of these new enum definitions?
I'm confused. If we're encouraging the use of plain strings, what is
On Wed, Apr 30, 2008 at 11:16 AM, Cassie <do...@google.com> wrote:
> Okay, so the opt_param to the fetchPersonAppData was approved already.
> It looks we want to add the same param to all of the getField methods. That
> sounds fine.
>
> Just fyi, here is the code change for fetchPersonAppData (minus comments so
> it is shorter):
>
> opensocial.EscapeType = {HTML_ESCAPE : 'htmlEscape', NONE : 'none'}; <----
> on opensocial. so we can reuse for all model objects
> opensocial.DataRequest.DataRequestFields = {ESCAPE_TYPE : 'escapeType'};
> opensocial.DataRequest.prototype.newFetchPersonAppDataRequest =
> function(idSpec, keys, opt_params) {};
>
> Here is what the getField addition would be:
>
> getField(name, opt_params);
>
> Usage:
> getField('name')
> or
> getField('name', {'escapeType' : 'none'}) <--- not super horrible... but
> we can definitely add sugar in 0.9
the point of these new enum definitions?