truncate microsummary file names to 60 characters to prevent nsIFile.createUnique from failing due to too-long names

Patch by Joey Minta.
bug=342212
r=myk
This commit is contained in:
myk@mozilla.org
2007-01-14 05:38:10 +00:00
parent 7ae7565e85
commit 673633ef34

View File

@@ -1829,6 +1829,7 @@ function getLoadedMicrosummaryResource(uri) {
*/
function sanitizeName(aName) {
const chars = "-abcdefghijklmnopqrstuvwxyz0123456789";
const maxLength = 60;
var name = aName.toLowerCase();
name = name.replace(/ /g, "-");
@@ -1847,6 +1848,9 @@ function sanitizeName(aName) {
name += chars.charAt(Math.round(Math.random() * (chars.length - 1)));
}
if (name.length > maxLength)
name = name.substring(0, maxLength);
return name;
}