CouchDB
  1. CouchDB
  2. COUCHDB-646

JSON object hidden from the sandbox for show and list

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.11
    • Fix Version/s: 0.11
    • Component/s: Build System
    • Labels:
    • Environment:

      CouchDB built from head. Ubuntu. JavaScript-C 1.7.0 2007-10-03

    • Skill Level:
      New Contributors Level (Easy)

      Description

      Three issues that I think are related so I have opened them as a single ticket.

      TheJSON object defined in main.js appears not to be available any more in show and list. I believe it was in a previous release.

      The form object.toJSON() does not seem to be working in show and list.

      var d = new Date(); toJSON(d) returns {} rather than a string. This also seems to be affecting views.

        Activity

        Hide
        Paul Joseph Davis added a comment -

        I don't see where we allowed the JSON object into the sandbox in 0.10, but even if we did it wouldn't solve the issue with JSON.stringify(new Date()). The new JSON.stringify relies on the Date prototype having a toJSON method that is defined in newer Spidermonkey's, but not in 1.7.

        The proper patch to get toJSON(new Date()) working would be to do as Jchris said in an email somewhere about adding a toJSON function when one doesn't exist. Which sounds ok in theory but I'm wondering if anyone can predict any issues before I go down that path.

        Show
        Paul Joseph Davis added a comment - I don't see where we allowed the JSON object into the sandbox in 0.10, but even if we did it wouldn't solve the issue with JSON.stringify(new Date()). The new JSON.stringify relies on the Date prototype having a toJSON method that is defined in newer Spidermonkey's, but not in 1.7. The proper patch to get toJSON(new Date()) working would be to do as Jchris said in an email somewhere about adding a toJSON function when one doesn't exist. Which sounds ok in theory but I'm wondering if anyone can predict any issues before I go down that path.
        Hide
        Cliff Stanford added a comment -

        json2.js has a Date.toJSON prototype. But it won't overwrite an existing one. The solution may be simply to let it walk over the inbuilt prototype which, presumably, doesn't work.

        Just taking out line 173 (and the }, obviously) would probably do the trick.

        Show
        Cliff Stanford added a comment - json2.js has a Date.toJSON prototype. But it won't overwrite an existing one. The solution may be simply to let it walk over the inbuilt prototype which, presumably, doesn't work. Just taking out line 173 (and the }, obviously) would probably do the trick.
        Hide
        Chris Anderson added a comment -

        I've committed a change in r911602 to explicitly add the JSON object to the sandbox. Maybe this will help...maybe not.

        Cliff do you mind checking to see if JSON.stringify is more useful now?

        Show
        Chris Anderson added a comment - I've committed a change in r911602 to explicitly add the JSON object to the sandbox. Maybe this will help...maybe not. Cliff do you mind checking to see if JSON.stringify is more useful now?
        Hide
        Cliff Stanford added a comment -

        Works fine now, thanks.

        Regards,
        Cliff.


        Cliff Stanford
        Might Limited +44 845 0045 666 (Office)
        Suite 67, Dorset House +44 7973 616 666 (Mobile)
        Duke Street, Chelmsford, CM1 1TB

        Show
        Cliff Stanford added a comment - Works fine now, thanks. Regards, Cliff. – Cliff Stanford Might Limited +44 845 0045 666 (Office) Suite 67, Dorset House +44 7973 616 666 (Mobile) Duke Street, Chelmsford, CM1 1TB
        Hide
        Sam Bisbee added a comment -

        This was fixed a long time ago by Chris and appears to have been in v0.11.0 (based on svn rev numbers). The commit now lives @ 82ff1a2b0a15dbe181221173f3013befab68f499.

        Show
        Sam Bisbee added a comment - This was fixed a long time ago by Chris and appears to have been in v0.11.0 (based on svn rev numbers). The commit now lives @ 82ff1a2b0a15dbe181221173f3013befab68f499.

          People

          • Assignee:
            Unassigned
            Reporter:
            Cliff Stanford
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development