Closed Bug 107771 Opened 23 years ago Closed 23 years ago

String.prototype.lastIndexOf counts on 0 termination of JSSTRING_CHARS

Categories

(Core :: JavaScript Engine, defect, P1)

x86
Windows 2000
defect

Tracking

()

VERIFIED FIXED
mozilla0.9.6

People

(Reporter: sean.schneyer, Assigned: brendan)

References

()

Details

(Keywords: js1.5, regression, testcase)

Attachments

(2 files)

From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.5+)
Gecko/20011030
BuildID:    2001103003

When going to the above URL, Javascript is used to redirect the user to
https://web1.e-travel.com/etravel40/bin/ETWebDll.dll/welcome?UserGroup=ericsson
In Mozilla, however, you are redirect to
https://web1.e-travel.com/etravel40/bin/ETWebDll.dll/welcome?UserGroup= instead.
The Javascript used is listed below:
---
var path = new String(document.location);
  k = path.lastIndexOf('/');
  if (k == path.length-1) {
    path = path.substring(0, k);
    k = path.lastIndexOf('/');
  }  

  var user_group = new String(path.substring(k+1, path.length));
  var html = new String;
  html = '/etravel40/bin/ETWebDll.dll/welcome?UserGroup=';
  html += user_group;
  top.location.href = html;
---

Reproducible: Always
Steps to Reproduce:
1. Go to https://web1.e-travel.com/ericsson
2. Redirected to
https://web1.e-travel.com/etravel40/bin/ETWebDll.dll/welcome?UserGroup= 


Actual Results:  Redirected to wrong URL:
https://web1.e-travel.com/etravel40/bin/ETWebDll.dll/welcome?UserGroup= 

Expected Results:  Redirected to correct URL:
https://web1.e-travel.com/etravel40/bin/ETWebDll.dll/welcome?UserGroup=ericsson
Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.5+) Gecko/20011031

Testcase in one moment.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: Javascript URL redirect not written correctly → Javascript not updating variable quickly enough for method call
Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.5+) Gecko/20011031

This is a regression from Mozilla 0.9.5 milestone, which correctly evaluates
this testcase.
Keywords: regression, testcase
This stinks of my dependent string fix for bug 56940.

/be
Assignee: rogerl → brendan
Keywords: js1.5, mozilla0.9.6
Priority: -- → P1
Target Milestone: --- → mozilla0.9.6
Fixing summary.  I hope there aren't more like this -- I'll look around.

/be
Status: NEW → ASSIGNED
Summary: Javascript not updating variable quickly enough for method call → String.prototype.lastIndexOf counts on 0 termination of JSSTRING_CHARS
A `grep '[a-z]\[.* == [a-zA-Z_][a-zA-Z0-9_]*\[' js*.[ch]` shows no other such
bad conditions.  I think this is it.  Our testcase failed to catch it, but will
once phil creates a regression test for this bug.

I have r=jag over my shoulder; jband, are you around?

/be
Comment on attachment 56017 [details] [diff] [review]
proposed fix, give me fast r= and sr= please!

Got r=jag, sr=waterson, woohoo!

/be
Attachment #56017 - Flags: superreview+
Attachment #56017 - Flags: review+
Fixed.

/be
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
I am totally impressed with the turnaround on this fix! Thanks, I'm confirming
that it works for me with the latest build.
Agreed -- Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.5+)
Gecko/20011101 testcase now passes :)
Status: RESOLVED → VERIFIED
Testcase added to JS testsuite:

          mozilla/js/tests/js1_5/String/regress-107771.js

Testcase passes in debug and optimized JS shells built 2001-11-01 WinNT.
Based on this and the results indicated above, marking VERIFIED FIXED.
Flags: testcase+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: