You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by do...@apache.org on 2008/02/15 01:20:17 UTC

svn commit: r627914 - in /incubator/shindig/trunk: features/opensocial-reference/opensocial.js features/opensocial-samplecontainer/samplecontainer.js javascript/samplecontainer/state-basicfriendlist.xml

Author: doll
Date: Thu Feb 14 16:20:16 2008
New Revision: 627914

URL: http://svn.apache.org/viewvc?rev=627914&view=rev
Log:
Made the samplecontainer more spec compliant.
- ids can not contain @ symbols
- activities are now validated for title or titleId
- app data keys now have their chars restricted


Modified:
    incubator/shindig/trunk/features/opensocial-reference/opensocial.js
    incubator/shindig/trunk/features/opensocial-samplecontainer/samplecontainer.js
    incubator/shindig/trunk/javascript/samplecontainer/state-basicfriendlist.xml

Modified: incubator/shindig/trunk/features/opensocial-reference/opensocial.js
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/features/opensocial-reference/opensocial.js?rev=627914&r1=627913&r2=627914&view=diff
==============================================================================
--- incubator/shindig/trunk/features/opensocial-reference/opensocial.js (original)
+++ incubator/shindig/trunk/features/opensocial-reference/opensocial.js Thu Feb 14 16:20:16 2008
@@ -131,6 +131,16 @@
  * @member opensocial
  */
 opensocial.requestCreateActivity = function(activity, priority, opt_callback) {
+  if (!activity || (!activity.getField(opensocial.Activity.Field.TITLE)
+      && !activity.getField(opensocial.Activity.Field.TITLE_ID))) {
+    if (opt_callback) {
+      opt_callback(new opensocial.ResponseItem(null, null,
+          opensocial.ResponseItem.Error.BAD_REQUEST,
+          "You must pass in an activity with a title or title id."));
+    }
+    return;
+  }
+
  opensocial.Container.get().requestCreateActivity(activity, priority,
      opt_callback);
 };

Modified: incubator/shindig/trunk/features/opensocial-samplecontainer/samplecontainer.js
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/features/opensocial-samplecontainer/samplecontainer.js?rev=627914&r1=627913&r2=627914&view=diff
==============================================================================
--- incubator/shindig/trunk/features/opensocial-samplecontainer/samplecontainer.js (original)
+++ incubator/shindig/trunk/features/opensocial-samplecontainer/samplecontainer.js Thu Feb 14 16:20:16 2008
@@ -168,6 +168,8 @@
 };
 
 
+var keyRestrictionExpr = /^[\w\.\-]*$/g;
+
 /**
  * This method returns the data requested about the viewer and his/her friends.
  * Since this is an in memory container, it is merely returning the member
@@ -273,6 +275,13 @@
       case 'UPDATE_PERSON_APP_DATA' :
         var userId = request.id;
         // Gadgets can only edit viewer data
+        if (!request.key.match(keyRestrictionExpr)) {
+          errorCode = opensocial.ResponseItem.Error.BAD_REQUEST;
+          errorMessage = "app data keys can only container alphanumeric "
+              + "characters, dots, dashes, or underscores";
+          break;
+        }
+
         if (userId == opensocial.DataRequest.PersonId.VIEWER
             || userId == this.viewer.getId()) {
           userId = this.viewer.getId();

Modified: incubator/shindig/trunk/javascript/samplecontainer/state-basicfriendlist.xml
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/samplecontainer/state-basicfriendlist.xml?rev=627914&r1=627913&r2=627914&view=diff
==============================================================================
--- incubator/shindig/trunk/javascript/samplecontainer/state-basicfriendlist.xml (original)
+++ incubator/shindig/trunk/javascript/samplecontainer/state-basicfriendlist.xml Thu Feb 14 16:20:16 2008
@@ -1,16 +1,16 @@
 <container>
   <viewer>
-    <person id="john.doe@mydomain.com" name="John Doe"></person>
+    <person id="john.doe" name="John Doe"></person>
   </viewer>
 
   <viewerFriends>
-     <person id="jane.doe@mydomain.com" name="Jane Doe"></person>
-     <person id="george.doe@mydomain.com" name="George Doe"></person>
+     <person id="jane.doe" name="Jane Doe"></person>
+     <person id="george.doe" name="George Doe"></person>
   </viewerFriends>
 
   <personAppData>
-    <data person="george.doe@mydomain.com" field="count">2</data>
-    <data person="jane.doe@mydomain.com" field="count">7</data>
+    <data person="george.doe" field="count">2</data>
+    <data person="jane.doe" field="count">7</data>
   </personAppData>
 
 </container>