rem: persist.saveURI(source, null, null, persistArgs.postData, null, persistArgs.target); 
add: persist.saveURI(source, null, getReferrer(document), persistArgs.postData, null, persistArgs.target); 
context: function foundHeaderInfo(aSniffer, aData, aSkipPrompt){  var contentType = aSniffer.contentType;  var contentEncodingType = aSniffer.contentEncodingType;  var shouldDecode = false;  // Are we allowed to decode?  try {    const helperAppService =      Components.classes["@mozilla.org/uriloader/external-helper-app-service;1"].        getService(Components.interfaces.nsIExternalHelperAppService);    var url = aSniffer.uri.QueryInterface(Components.interfaces.nsIURL);    var urlExt = url.fileExtension;    if (helperAppService.applyDecodingForExtension(urlExt,                                                   contentEncodingType)) {      shouldDecode = true;    }  }  catch (e) {  }  var isDocument = aData.document != null && isDocumentType(contentType);  if (!isDocument && !shouldDecode && contentEncodingType) {    // The data is encoded, we are not going to decode it, and this is not a    // document save so we won't be doing a "save as, complete" (which would    // break if we reset the type here).  So just set our content type to    // correspond to the outermost encoding so we get extensions and the like    // right.    contentType = contentEncodingType;  }    var file = null;  var saveAsType = kSaveAsType_URL;  try {    file = aData.fileName.QueryInterface(Components.interfaces.nsILocalFile);  }  catch (e) {    var saveAsTypeResult = { rv: 0 };    file = getTargetFile(aData, aSniffer, contentType, isDocument, aSkipPrompt, saveAsTypeResult);    saveAsType = saveAsTypeResult.rv;  }  // If we're saving a document, and are saving either in complete mode or   // as converted text, pass the document to the web browser persist component.  // If we're just saving the HTML (second option in the list), send only the URI.  var source = (isDocument && saveAsType != kSaveAsType_URL) ? aData.document : aSniffer.uri;  var persistArgs = {    source      : source,    contentType : (isDocument && saveAsType == kSaveAsType_Text) ? "text/plain" : contentType,    target      : file,    postData    : aData.document ? getPostData() : null,    bypassCache : aData.bypassCache  };    var persist = makeWebBrowserPersist();  // Calculate persist flags.  const nsIWBP = Components.interfaces.nsIWebBrowserPersist;  const flags = nsIWBP.PERSIST_FLAGS_NO_CONVERSION | nsIWBP.PERSIST_FLAGS_REPLACE_EXISTING_FILES;  if (aData.bypassCache)    persist.persistFlags = flags | nsIWBP.PERSIST_FLAGS_BYPASS_CACHE;  else     persist.persistFlags = flags | nsIWBP.PERSIST_FLAGS_FROM_CACHE;  if (shouldDecode)    persist.persistFlags &= ~nsIWBP.PERSIST_FLAGS_NO_CONVERSION;      // Create download and initiate it (below)  var dl = Components.classes["@mozilla.org/download;1"].createInstance(Components.interfaces.nsIDownload);  if (isDocument && saveAsType != kSaveAsType_URL) {    // Saving a Document, not a URI:    var filesFolder = null;    if (persistArgs.contentType != "text/plain") {      // Create the local directory into which to save associated files.       const nsILocalFile = Components.interfaces.nsILocalFile;      const lfContractID = "@mozilla.org/file/local;1";      filesFolder = Components.classes[lfContractID].createInstance(nsILocalFile);      filesFolder.initWithPath(persistArgs.target.path);            var nameWithoutExtension = filesFolder.leafName;      nameWithoutExtension = nameWithoutExtension.substring(0, nameWithoutExtension.lastIndexOf("."));      var filesFolderLeafName = getStringBundle().formatStringFromName("filesFolder",                                                                       [nameWithoutExtension],                                                                       1);      filesFolder.leafName = filesFolderLeafName;    }          var encodingFlags = 0;    if (persistArgs.contentType == "text/plain") {      encodingFlags |= nsIWBP.ENCODE_FLAGS_FORMATTED;      encodingFlags |= nsIWBP.ENCODE_FLAGS_ABSOLUTE_LINKS;      encodingFlags |= nsIWBP.ENCODE_FLAGS_NOFRAMES_CONTENT;            }        const kWrapColumn = 80;    dl.init(aSniffer.uri, persistArgs.target, null, null, null, persist);    persist.saveDocument(persistArgs.source, persistArgs.target, filesFolder,                          persistArgs.contentType, encodingFlags, kWrapColumn);  } else {    dl.init(source, persistArgs.target, null, null, null, persist);    persist.saveURI(source, null, null, persistArgs.postData, null, persistArgs.target);  }}
meta: 9421	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/9421/2b57829e82063609549c0eedadb5413412d97620/contentAreaUtils.js/buggy/browser/base/content/contentAreaUtils.js