Range.toString() contains JavaScript code

RESOLVED INVALID

Status

()

RESOLVED INVALID
17 years ago
6 years ago

People

(Reporter: ajybhatia, Assigned: peterv)

Tracking

({ecommerce, topembed})

Trunk
x86
Windows 98
ecommerce, topembed
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: topembed, URL)

Attachments

(1 attachment)

(Reporter)

Description

17 years ago
The string returned by Range.toString() should only contain text visible
in the browser, IMO. However, it contains any JavaScript found within
the Range, as well.

Reproducibility: Every time.

Steps to Reproduce:
1. Load the URL
http://blues.mcom.com/users/ajybhatia/publish/RangeBugTestCase.htm in Mozilla.
2. Click on the button marked "Click Here".

Actual Results:
The alert that pops up displays Range.toString() for a Range that selects the
contents of the Body node. This also displays JavaScript contained within the
Body.

Expected Results:
The Range should only have the text "to see contents of Body node."
No JavaScript should be part of the selected range.
Could you please attach the testcase to the bug?  Testcases behind the firewall
are really hard to work with if you're outside....
Status: UNCONFIRMED → NEW
Ever confirmed: true

Comment 2

17 years ago
Here is the source of the HTML referenced at the URL:

<html>
<head>
<title>Range Bug TestCase</title>
<script language=JavaScript>
function displayRangeContents()
    {
      var Doc = window.content.document;
      var Range = Doc.createRange();
      Range.selectNodeContents(Doc.body);
      alert("The body of this page contains: " + Range.toString());
    }
    </SCRIPT>
</head>
<body>
<script language=JavaScript>
function dummyFunction()
    {
      // All sorts of cool stuff here...
    }
    </SCRIPT>
<form>
<input type=button value="Click Here" onClick="javascript:displayRangeContents()">
to see contents of Body node.
    </form>
</body>
</html>

(Reporter)

Updated

17 years ago
Keywords: ecommerce, topembed
Whiteboard: topembed

Comment 3

17 years ago
reassigning to jst because nisheeth is on sabbatical.
Assignee: anthonyd → jst
Over to peterv who now works on the serializers.
Assignee: jst → peterv
(Assignee)

Comment 5

17 years ago
I'm not convinced that that would be the right thing to do. The spec says:

"One can get a copy of all the character data selected or partially selected by
a Range with:

DOMString toString();

This does nothing more than simply concatenate all the character data selected
by the Range. This includes character data in both Text and CDATASection nodes."

Note the *all* in the first sentence. Marking INVALID. If you disagree, reopen it.
Status: NEW → RESOLVED
Last Resolved: 17 years ago
Resolution: --- → INVALID

Comment 6

17 years ago
The brand "M" browser engine provides access to a document's text (without 
javascript).

Below is what we are trying to emulate:

<HTML>
  <HEAD>
    <TITLE>Range Bug TestCase</TITLE>
    <SCRIPT language=JavaScript>
    function displayRangeContents()
    {
        var Range = document.body.createTextRange();
        
        alert("The body of this page contains: " + Range.text);
    }
    </SCRIPT>
  </HEAD>
  <BODY>
    <SCRIPT language=JavaScript>
    function dummyFunction()
    {
      // All sorts of cool stuff here...
    }
    </SCRIPT>
    <FORM>
      <INPUT type=button value="Click Here" 
onClick="javascript:displayRangeContents()">
       to see contents of Body node.
    </FORM>
  </BODY>
</HTML>

Comment 7

17 years ago
Created attachment 58444 [details]
Demo of Text Range for IE 5.5

We require this functionality for Mozilla for Quick Checkout Form Fill, a
shipping product currently using IE.
Component: DOM: Traversal-Range → DOM: Core & HTML
Product: Core → Core
You need to log in before you can comment on or make changes to this bug.