rem: octetArray = octetArray.replace(/\n /, ""); 
add: for (var i=octetArray.length-2; i>=0; i--) { if (octetArray[i] == "\n" && octetArray[i+1] == " ") { octetArray = octetArray.splice(i, 2); } } 
context: function ics_importFromStream(aStream, aCount) {    var items = new Array();    // Read in the string. Note that it isn't a real string at this point, because    // likely, the file is utf8. The multibyte chars show up as multiple 'chars'    // in this string. So call it an array of octets for now.        var octetArray = "";    var scriptableInputStream = Components.classes["@mozilla.org/scriptableinputstream;1"]                                          .createInstance(Components.interfaces.nsIScriptableInputStream);    scriptableInputStream.init(aStream);    octetArray = scriptableInputStream.read(-1);    // Some other apps (most notably, sunbird 0.2) happily splits an utf8 character    // between the octets, and adds a newline and space between them, for ics    // folding. Unfold manually before parsing the file as utf8.    // This is utf8 safe, because octets with the first bit 0 are always one-octet    // characters. So the space or the newline never can be part of a multi-byte    // char.    octetArray = octetArray.replace(/\n /, "");    // Interpret the byte-array as an utf8 string, and convert into a    // javascript string.    var unicodeConverter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"]                                     .createInstance(Components.interfaces.nsIScriptableUnicodeConverter);    // ics files are always utf8    unicodeConverter.charset = "UTF-8";    var str = unicodeConverter.ConvertFromUnicode(octetArray);    icssrv = Components.classes["@mozilla.org/calendar/ics-service;1"]                       .getService(Components.interfaces.calIICSService);    var rootComp = icssrv.parseICS(str);    var calComp;    // libical returns the vcalendar component if there is just    // one vcalendar. If there are multiple vcalendars, it returns    // an xroot component, with those vcalendar childs. We need to    // handle both.    if (rootComp.componentType == 'VCALENDAR') {        calComp = rootComp;    } else {        calComp = rootComp.getFirstSubcomponent('VCALENDAR');    }    while (calComp) {        var subComp = calComp.getFirstSubcomponent("ANY");        while (subComp) {            switch (subComp.componentType) {            case "VEVENT":                var event = Components.classes["@mozilla.org/calendar/event;1"]                                      .createInstance(Components.interfaces.calIEvent);                event.icalComponent = subComp;                items.push(event);                break;            case "VTODO":                var todo = Components.classes["@mozilla.org/calendar/todo;1"]                                     .createInstance(Components.interfaces.calITodo);                todo.icalComponent = subComp;                items.push(todo);                break;            default:                // Nothing            }            subComp = calComp.getNextSubcomponent("ANY");        }        calComp = rootComp.getNextSubcomponent('VCALENDAR');    }    aCount.value = items.length;    return items;};
meta: 8395	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/8395/a733684645317271d828a1c1ae625db5ac7c60e9/calIcsImportExport.js/clean/calendar/import-export/calIcsImportExport.js