Spurious security error when accessing pop-up data

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • KKramsch

    #1

    Spurious security error when accessing pop-up data




    My code is generating this type of error:

    Security Error: Content at http://nonexistent.org/somepage.html
    may not load data from about:blank.

    The "about:blan k" page mentioned in the error message is a pop-up
    window, whose content is 100% dynamically-generated, and which is
    in fact *owes its existence* to code in the referring page
    (nonexistent.or g/somepage.html), along the lines of something like

    window.open("", "pop-up", "width=450,heig ht=300,resizabl e");

    So, AFAICT, the error is spurious (i.e. there's really no security
    breach). Is there any way to inform the browser that "about:blan k"
    does belong to nonexistent.org ?

    Thanks!

    Karl


    --
    Sent from a spam-bucket account; I check it once in a blue moon. If
    you still want to e-mail me, cut out the extension from my address,
    and make the obvious substitutions on what's left.
  • Grant Wagner

    #2
    Re: Spurious security error when accessing pop-up data

    KKramsch wrote:
    [color=blue]
    > My code is generating this type of error:
    >
    > Security Error: Content at http://nonexistent.org/somepage.html
    > may not load data from about:blank.
    >
    > The "about:blan k" page mentioned in the error message is a pop-up
    > window, whose content is 100% dynamically-generated, and which is
    > in fact *owes its existence* to code in the referring page
    > (nonexistent.or g/somepage.html), along the lines of something like
    >
    > window.open("", "pop-up", "width=450,heig ht=300,resizabl e");
    >
    > So, AFAICT, the error is spurious (i.e. there's really no security
    > breach). Is there any way to inform the browser that "about:blan k"
    > does belong to nonexistent.org ?
    >
    > Thanks!
    >
    > Karl[/color]

    about:blank and any page loaded from your domain are indeed from
    completely different domains, and should not be able to modify each
    others' content.

    Just use:

    window.open("bl ank.htm" ...);

    and in blank.htm:

    <html>
    <head>
    <title>blank.ht m</title>
    </head>
    <body onload="if (opener && opener.callBack ) opener.callBack ();">
    </body>
    </html>

    Now the document in the newly opened window has also originated from
    your domain. Also, you now have a way to trigger a script in the opener
    once you are sure the new document has completely loaded (and there is
    in fact a document object in the new window to be manipulated).

    --
    Grant Wagner <gwagner@agrico reunited.com>
    comp.lang.javas cript FAQ - http://jibbering.com/faq


    Comment

    • KKramsch

      #3
      Re: Spurious security error when accessing pop-up data

      In <40F59C07.FE42B 6AD@agricoreuni ted.com> Grant Wagner <gwagner@agrico reunited.com> writes:
      [color=blue]
      >KKramsch wrote:[/color]
      [color=blue][color=green]
      >> My code is generating this type of error:
      >>
      >> Security Error: Content at http://nonexistent.org/somepage.html
      >> may not load data from about:blank.
      >>
      >> The "about:blan k" page mentioned in the error message is a pop-up
      >> window, whose content is 100% dynamically-generated, and which is
      >> in fact *owes its existence* to code in the referring page
      >> (nonexistent.or g/somepage.html), along the lines of something like
      >>
      >> window.open("", "pop-up", "width=450,heig ht=300,resizabl e");
      >>
      >> So, AFAICT, the error is spurious (i.e. there's really no security
      >> breach). Is there any way to inform the browser that "about:blan k"
      >> does belong to nonexistent.org ?
      >>
      >> Thanks!
      >>
      >> Karl[/color][/color]
      [color=blue]
      >about:blank and any page loaded from your domain are indeed from
      >completely different domains, and should not be able to modify each
      >others' content.[/color]
      [color=blue]
      >Just use:[/color]
      [color=blue]
      >window.open("b lank.htm" ...);[/color]
      [color=blue]
      >and in blank.htm:[/color]
      [color=blue]
      ><html>
      ><head>
      ><title>blank.h tm</title>
      ></head>
      ><body onload="if (opener && opener.callBack ) opener.callBack ();">
      ></body>
      ></html>[/color]

      Hi! Thanks! But isn't there a way to do this without requiring
      a dummy blank.htm file being physically on the disk?

      Karl



      --
      Sent from a spam-bucket account; I check it once in a blue moon. If
      you still want to e-mail me, cut out the extension from my address,
      and make the obvious substitutions on what's left.

      Comment

      • KKramsch

        #4
        Re: Spurious security error when accessing pop-up data

        In <cd6ov8$13u$1@r eader2.panix.co m> KKramsch <karlUNDERSCORE kramsch@yahooPE RIODcom.invalid > writes:
        [color=blue]
        >In <40F59C07.FE42B 6AD@agricoreuni ted.com> Grant Wagner <gwagner@agrico reunited.com> writes:[/color]
        [color=blue][color=green]
        >>KKramsch wrote:[/color][/color]
        [color=blue][color=green][color=darkred]
        >>> My code is generating this type of error:
        >>>
        >>> Security Error: Content at http://nonexistent.org/somepage.html
        >>> may not load data from about:blank.
        >>>
        >>> The "about:blan k" page mentioned in the error message is a pop-up
        >>> window, whose content is 100% dynamically-generated, and which is
        >>> in fact *owes its existence* to code in the referring page
        >>> (nonexistent.or g/somepage.html), along the lines of something like
        >>>
        >>> window.open("", "pop-up", "width=450,heig ht=300,resizabl e");
        >>>
        >>> So, AFAICT, the error is spurious (i.e. there's really no security
        >>> breach). Is there any way to inform the browser that "about:blan k"
        >>> does belong to nonexistent.org ?
        >>>
        >>> Thanks!
        >>>
        >>> Karl[/color][/color][/color]
        [color=blue][color=green]
        >>about:blank and any page loaded from your domain are indeed from
        >>completely different domains, and should not be able to modify each
        >>others' content.[/color][/color]
        [color=blue][color=green]
        >>Just use:[/color][/color]
        [color=blue][color=green]
        >>window.open(" blank.htm" ...);[/color][/color]
        [color=blue][color=green]
        >>and in blank.htm:[/color][/color]
        [color=blue][color=green]
        >><html>
        >><head>
        >><title>blank. htm</title>
        >></head>
        >><body onload="if (opener && opener.callBack ) opener.callBack ();">
        >></body>
        >></html>[/color][/color]
        [color=blue]
        > Hi! Thanks! But isn't there a way to do this without requiring
        >a dummy blank.htm file being physically on the disk?[/color]



        After my last post it occurred to me that it would be better to
        post more code. The code in question belongs to a utilities
        JavaScript "module" for use by all my CGI scripts; it includes the
        following methods (error occurs in the console() method):

        var Console;

        function maybe_open_cons ole() {
        if (!Console || Console.closed) {
        Console = window.open("", "console","widt h=600,height=30 0,resizable");
        }
        try {
        return Console.documen t && Console.documen t.open;
        }
        catch (ex) { return false; }
        }

        function console(msg) {
        if (maybe_open_con sole()) {
        var d = Console.documen t;

        // The next line of code causes the security error
        d.open("text/plain");

        d.write(msg);
        d.close();
        }
        }


        The console() method is to be used for debugging purposes. It
        pops up a window if necessary and writes a message to it. I have
        indicated the line in it that causes the error.

        Since I want this method to be usable by any CGI script, I'd like
        to minimize dependencies on other files (such as a dummmy blank.htm
        file somewhere below docroot).

        Any suggestions on how to implement this would be much appreciated!

        Karl

        --
        Sent from a spam-bucket account; I check it once in a blue moon. If
        you still want to e-mail me, cut out the extension from my address,
        and make the obvious substitutions on what's left.

        Comment

        • Grant Wagner

          #5
          Re: Spurious security error when accessing pop-up data

          KKramsch wrote:
          [color=blue]
          > In <40F59C07.FE42B 6AD@agricoreuni ted.com> Grant Wagner <gwagner@agrico reunited.com> writes:
          >[color=green]
          > >about:blank and any page loaded from your domain are indeed from
          > >completely different domains, and should not be able to modify each
          > >others' content.[/color]
          >[color=green]
          > >Just use:[/color]
          >[color=green]
          > >window.open("b lank.htm" ...);[/color]
          >[color=green]
          > >and in blank.htm:[/color]
          >[color=green]
          > ><html>
          > ><head>
          > ><title>blank.h tm</title>
          > ></head>
          > ><body onload="if (opener && opener.callBack ) opener.callBack ();">
          > ></body>
          > ></html>[/color]
          >
          > Hi! Thanks! But isn't there a way to do this without requiring
          > a dummy blank.htm file being physically on the disk?[/color]

          <script type="text/javascript">
          var Console;
          function console(msg) {
          var content = '<html>' +
          '<head>' +
          '<title>Console </title>' +
          '</head>' +
          '<body>' + '<pre>' +
          msg +
          '</pre>' + '</body>' +
          '</html>';
          if (!Console || Console.closed) {
          Console = window.open(
          "javascript :'" + content + "'",
          "console",
          "width=600,heig ht=300,resizabl e"
          );
          } else {
          Console.documen t.open();
          Console.documen t.write(content );
          Console.documen t.close();
          Console.focus() ;
          }
          }
          </script>
          <a href="#" onclick="consol e('hi there');return false;">Click this first</a>
          <br>
          <a href="#" onclick="consol e('already open');return false;">Click this second *before* closing
          the console window</a>

          Tested and working in: IE6SP1, Netscape 4.78, Firefox 0.9.2 and Mozilla 1.7.1

          In Opera 7.52, you get:
          Event thread: onclick
          Error:
          name: ReferenceError
          message: Security error: attempted to read protected variable

          on the second call to console(). Uncommenting the alert() reveals that Console is "object
          inaccessible".

          The fact that it works in Firefox and Mozilla tells me that either it's one of the following:
          a) an overly zealous security model in Opera b) a bug in Opera c) a bug in the security model
          of Gecko and what I'm doing really shouldn't be allowed.

          I'm guessing (and hoping) it's a) or b).

          It doesn't work at all in Opera 6.05.

          --
          Grant Wagner <gwagner@agrico reunited.com>
          comp.lang.javas cript FAQ - http://jibbering.com/faq

          Comment

          Working...