mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-26 18:31:29 +00:00
fix for bug 83489 - fix the url-duping code in session history so that we don't throw exceptions on badly formed urls
r=dougt, sr=blizzard, a=chofmann
This commit is contained in:
parent
960e7f07cf
commit
d400e644ab
@ -136,33 +136,56 @@ function addToUrlbarHistory()
|
||||
var unused = { };
|
||||
var scheme = ioService.extractScheme(urlToAdd, unused, unused);
|
||||
} catch(e) {
|
||||
urlToAdd = "http://" + urlToAdd;
|
||||
urlToAdd = "http://" + urlToAdd;
|
||||
}
|
||||
|
||||
try {
|
||||
var uriToAdd = ioService.newURI(urlToAdd, null);
|
||||
}
|
||||
catch(e) {
|
||||
// it isn't a valid url
|
||||
// we'll leave uriToAdd as "undefined" and handle that later
|
||||
}
|
||||
var uriToAdd = ioService.newURI(urlToAdd, null);
|
||||
|
||||
while(elements.hasMoreElements()) {
|
||||
entry = elements.getNext();
|
||||
if (entry) {
|
||||
index ++;
|
||||
entry= entry.QueryInterface(Components.interfaces.nsIRDFLiteral);
|
||||
var rdfValue = entry.Value;
|
||||
if (!entry) continue;
|
||||
|
||||
try {
|
||||
var unused = { };
|
||||
var scheme = ioService.extractScheme(rdfValue, unused, unused);
|
||||
} catch(e) {
|
||||
rdfValue = "http://" + rdfValue;
|
||||
index ++;
|
||||
entry= entry.QueryInterface(Components.interfaces.nsIRDFLiteral);
|
||||
var rdfValue = entry.Value;
|
||||
|
||||
try {
|
||||
var unused = { };
|
||||
var scheme = ioService.extractScheme(rdfValue, unused, unused);
|
||||
} catch(e) {
|
||||
rdfValue = "http://" + rdfValue;
|
||||
}
|
||||
|
||||
if (uriToAdd) {
|
||||
try {
|
||||
var rdfUri = ioService.newURI(rdfValue, null);
|
||||
|
||||
if (rdfUri.equals(uriToAdd)) {
|
||||
// URI already present in the database
|
||||
// Remove it from its current position.
|
||||
// It is inserted to the top after the while loop.
|
||||
entries.RemoveElementAt(index, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// the uri is still not recognized by the ioservice
|
||||
catch(ex) {
|
||||
// no problem, we'll handle this below
|
||||
}
|
||||
}
|
||||
|
||||
var rdfUri = ioService.newURI(rdfValue, null);
|
||||
|
||||
if (rdfUri.equals(uriToAdd)) {
|
||||
// URI already present in the database
|
||||
// Remove it from its current position.
|
||||
// It is inserted to the top after the while loop.
|
||||
entries.RemoveElementAt(index, true);
|
||||
break;
|
||||
}
|
||||
// if we got this far, then something is funky with the URIs,
|
||||
// so we need to do a straight string compare of the raw strings
|
||||
if (urlToAdd == rdfValue) {
|
||||
entries.RemoveElementAt(index, true);
|
||||
break;
|
||||
}
|
||||
} // while
|
||||
|
||||
@ -176,7 +199,7 @@ function addToUrlbarHistory()
|
||||
// this grow without bound.
|
||||
for (index = entries.GetCount(); index > MAX_HISTORY_ITEMS; --index) {
|
||||
entries.RemoveElementAt(index, true);
|
||||
} // for
|
||||
} // for
|
||||
} // localstore
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user