232587 - firefox goes into an infinite loop when using Save Link to Disk to overwrite a file with no dots in the filename. patch by pike, <pike@pikey.me.uk>, r=ben@mozilla.org

This commit is contained in:
ben%bengoodger.com 2004-05-21 08:49:38 +00:00
parent 796efc7376
commit a90ed91635
2 changed files with 8 additions and 8 deletions

View File

@ -419,13 +419,13 @@ function getTargetFile(aData, aSniffer, aContentType, aIsDocument, aSkipPrompt,
while (file.exists()) {
var parts = /.+-(\d+)(\..*)?$/.exec(file.leafName);
if (parts) {
file.leafName = file.leafName.replace(/((\d+)\.)/,
function (str, p1, part, s) {
return (parseInt(part) + 1) + ".";
file.leafName = file.leafName.replace(/((\d+)\.)|((\d+)$)/,
function (str, dot, dotNum, noDot, noDotNum, pos, s) {
return (parseInt(str) + 1) + (dot ? "." : "");
});
}
else {
file.leafName = file.leafName.replace(/\./, "-1$&");
file.leafName = file.leafName.replace(/\.|$/, "-1$&");
}
}

View File

@ -267,13 +267,13 @@ nsUnknownContentTypeDialog.prototype = {
while (aLocalFile.exists()) {
var parts = /.+-(\d+)(\..*)?$/.exec(aLocalFile.leafName);
if (parts) {
aLocalFile.leafName = aLocalFile.leafName.replace(/((\d+)\.)/,
function (str, p1, part, s) {
return (parseInt(part) + 1) + ".";
aLocalFile.leafName = aLocalFile.leafName.replace(/((\d+)\.)|((\d+)$)/,
function (str, dot, dotNum, noDot, noDotNum, pos, s) {
return (parseInt(str) + 1) + (dot ? "." : "");
});
}
else {
aLocalFile.leafName = aLocalFile.leafName.replace(/\./, "-1$&");
aLocalFile.leafName = aLocalFile.leafName.replace(/\.|$/, "-1$&");
}
}