Ticket #1808: Diff-enable-dom-object-save.patch
| File Diff-enable-dom-object-save.patch, 3.6 KB (added by fbennett, 6 years ago) |
|---|
-
chrome/content/zotero/xpcom/attachments.js
492 492 * Save a snapshot -- uses synchronous WebPageDump or asynchronous saveURI() 493 493 */ 494 494 function importFromDocument(document, sourceItemID, forceTitle, parentCollectionIDs, callback, libraryID) { 495 var url, bases, base, pos, len; 495 496 Zotero.debug('Importing attachment from document'); 496 497 497 498 if (sourceItemID && parentCollectionIDs) { … … 501 502 parentCollectionIDs = undefined; 502 503 } 503 504 504 var url = document.location.href; 505 if (document.location) { 506 url = document.location.href; 507 } else { 508 // 509 // For documents generated internally with createDocument(), 510 // attempts to query the document URL produce the following 511 // results: 512 // 513 // document.baseURIObject.spec: about:blank 514 // document.location: null 515 // 516 // To process XHTML documents of this kind as attachments, 517 // set a base element inside the HEAD node of the document. 518 // If no base element is present, a generated attachment 519 // document will fail. 520 // 521 url = "about:blank"; 522 var html = document.getElementsByTagName("html")[0]; 523 bases = html.getElementsByTagName("base"); 524 len = bases.length; 525 for (pos = 0; pos < len; pos += 1) { 526 base = bases.item(pos); 527 if (base.hasAttribute("href")) { 528 url = base.getAttribute("href"); 529 break; 530 } 531 } 532 } 505 533 var title = forceTitle ? forceTitle : document.title; 506 534 var mimeType = document.contentType; 507 535 var charsetID = Zotero.CharacterSets.getID(document.characterSet); … … 567 595 } 568 596 569 597 if (mimeType == 'text/html') { 598 Zotero.debug('Saving with wpdDOMSaver.saveHTMLDocument()'); 570 599 var sync = true; 571 600 572 601 // Load WebPageDump code -
chrome/content/zotero/webpagedump/domsaver.js
176 176 // Added by Dan S. for Zotero, replacing three lines below 177 177 this.document = document; 178 178 this.setFrameList(document.defaultView); 179 this.baseURL = document.location.href; 179 if (document.location) { 180 this.baseURL = document.location.href; 181 } else { 182 this.baseURL = "about:blank"; 183 } 180 184 181 185 182 186 // Set the document and frames … … 732 736 this.fileInfo[newFileName] = new Array("url","downloaded"); 733 737 this.fileInfo[newFileName]["url"] = aURLSpec; 734 738 this.fileInfo[newFileName]["downloaded"] = true; 735 if (aDownload) 736 this.fileInfo[newFileName]["downloaded"] = wpdCommon.downloadFile(aURLSpec,this.currentDir+newFileName); 739 if (aDownload) { 740 this.fileInfo[newFileName]["downloaded"] = wpdCommon.downloadFile(aURLSpec,this.currentDir+newFileName); 741 } 737 742 } 738 743 return newFileName; 739 744 } catch(ex) { … … 1058 1063 { 1059 1064 // we have to set a new current url which is the 1060 1065 // base reference url (necessary for frame processing) 1061 this.currentURL = aDocument.location.href; 1066 if (aDocument.location) { 1067 this.currentURL = aDocument.location.href; 1068 } else { 1069 this.currentURL = "about:blank"; 1070 } 1062 1071 1063 1072 // distinguish between HTML Documents and other 1064 1073 // embedded files like flash, video or images...