single-file-core 1.5.112 → 1.5.114

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,50 @@
1
+ /*
2
+ * Copyright 2010-2026 Gildas Lormeau
3
+ * contact : gildas.lormeau <at> gmail.com
4
+ *
5
+ * This file is part of SingleFile.
6
+ *
7
+ * The code in this file is free software: you can redistribute it and/or
8
+ * modify it under the terms of the GNU Affero General Public License
9
+ * (GNU AGPL) as published by the Free Software Foundation, either version 3
10
+ * of the License, or (at your option) any later version.
11
+ *
12
+ * The code in this file is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
15
+ * General Public License for more details.
16
+ *
17
+ * As additional permission under GNU AGPL version 3 section 7, you may
18
+ * distribute UNMODIFIED VERSIONS OF THIS file without the copy of the GNU
19
+ * AGPL normally required by section 4, provided you include this license
20
+ * notice and a URL through which recipients can access the Corresponding
21
+ * Source.
22
+ */
23
+
24
+ // this module is imported by the script embedded in self-extracting archives, it
25
+ // must stay free of dependencies
26
+
27
+ export {
28
+ getDoctypeString
29
+ };
30
+
31
+ function getDoctypeString(doc) {
32
+ const docType = doc.doctype;
33
+ let docTypeString = "";
34
+ if (docType) {
35
+ docTypeString = "<!DOCTYPE " + docType.nodeName;
36
+ if (docType.publicId) {
37
+ docTypeString += " PUBLIC \"" + docType.publicId + "\"";
38
+ if (docType.systemId) {
39
+ docTypeString += " \"" + docType.systemId + "\"";
40
+ }
41
+ } else if (docType.systemId) {
42
+ docTypeString += " SYSTEM \"" + docType.systemId + "\"";
43
+ }
44
+ if (docType.internalSubset) {
45
+ docTypeString += " [" + docType.internalSubset + "]";
46
+ }
47
+ docTypeString += ">";
48
+ }
49
+ return docTypeString;
50
+ }
package/core/util.js CHANGED
@@ -24,6 +24,7 @@
24
24
  import * as vendor from "./../vendor/index.js";
25
25
  import * as modules from "./../modules/index.js";
26
26
  import * as helper from "./helper.js";
27
+ import { getDoctypeString } from "./lib/doctype.js";
27
28
 
28
29
  const DEBUG = false;
29
30
  const ONE_MB = 1024 * 1024;
@@ -489,24 +490,6 @@ function guessMIMEType(expectedType, buffer) {
489
490
  }
490
491
  }
491
492
 
492
- function getDoctypeString(doc) {
493
- const docType = doc.doctype;
494
- let docTypeString = "";
495
- if (docType) {
496
- docTypeString = "<!DOCTYPE " + docType.nodeName;
497
- if (docType.publicId) {
498
- docTypeString += " PUBLIC \"" + docType.publicId + "\"";
499
- if (docType.systemId)
500
- docTypeString += " \"" + docType.systemId + "\"";
501
- } else if (docType.systemId)
502
- docTypeString += " SYSTEM \"" + docType.systemId + "\"";
503
- if (docType.internalSubset)
504
- docTypeString += " [" + docType.internalSubset + "]";
505
- docTypeString += "> ";
506
- }
507
- return docTypeString;
508
- }
509
-
510
493
  function log(...args) {
511
494
  console.log("S-File <browser>", ...args); // eslint-disable-line no-console
512
495
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "single-file-core",
3
- "version": "1.5.112",
3
+ "version": "1.5.114",
4
4
  "description": "SingleFile Core",
5
5
  "author": "Gildas Lormeau",
6
6
  "license": "AGPL-3.0-or-later",
@@ -23,6 +23,8 @@
23
23
 
24
24
  /* global DOMParser, setTimeout */
25
25
 
26
+ import { getDoctypeString } from "./../../core/lib/doctype.js";
27
+
26
28
  export {
27
29
  display
28
30
  };
@@ -89,21 +91,4 @@ async function display(document, docContent, { disableFramePointerEvents, inPlac
89
91
  });
90
92
  document.documentElement.setAttribute("data-sfz", "");
91
93
  document.querySelectorAll("link[rel*=icon]").forEach(element => element.replaceWith(element.cloneNode(true)));
92
- function getDoctypeString(doc) {
93
- const docType = doc.doctype;
94
- let docTypeString = "";
95
- if (docType) {
96
- docTypeString = "<!DOCTYPE " + docType.nodeName;
97
- if (docType.publicId) {
98
- docTypeString += " PUBLIC \"" + docType.publicId + "\"";
99
- if (docType.systemId)
100
- docTypeString += " \"" + docType.systemId + "\"";
101
- } else if (docType.systemId)
102
- docTypeString += " SYSTEM \"" + docType.systemId + "\"";
103
- if (docType.internalSubset)
104
- docTypeString += " [" + docType.internalSubset + "]";
105
- docTypeString += "> ";
106
- }
107
- return docTypeString;
108
- }
109
94
  }
@@ -113,7 +113,9 @@ const MAX_APPENDED_DATA_LENGTH = 65535;
113
113
  const PDF_ENTRY_FILENAME = "page.pdf";
114
114
  const PDF_HEADER_MAX_OFFSET = 1024;
115
115
  const MINIMAL_DOCTYPE = "<!DOCTYPE html>";
116
- const UNHIDDEN_FACE_WARNING_MESSAGE = "SingleFile: the archive was written without a face, its data names every wrapper tag:";
116
+ const UNHIDDEN_FACE_WARNING_MESSAGE = "SingleFile: the page data contains every HTML tag that could hide an embedded file, the archive was written without its";
117
+ const EMBEDDED_IMAGE_LABEL = "PNG image";
118
+ const EMBEDDED_PDF_LABEL = "PDF document";
117
119
  const LOCAL_FILE_HEADER_SIGNATURE = 0x04034b50;
118
120
  const CENTRAL_FILE_HEADER_SIGNATURE = 0x02014b50;
119
121
  const END_OF_CENTRAL_DIR_SIGNATURE = 0x06054b50;
@@ -181,7 +183,7 @@ async function createArchive(pageData, options, script, writeEntries, lastModDat
181
183
  if (options.embeddedImage && options.selfExtractingArchive) {
182
184
  imageChunk = getImageHTMLChunk(pageData, options, lastModDate);
183
185
  if (!imageChunk) {
184
- dropUnhiddenFace(options, "embeddedImage");
186
+ dropUnhiddenFace(options, "embeddedImage", EMBEDDED_IMAGE_LABEL);
185
187
  }
186
188
  }
187
189
  if (options.embeddedImage) {
@@ -582,7 +584,7 @@ function getStartHTMLArray(pageData, options, lastModDate, startTag = "") {
582
584
  const embeddedPdfText = TEXT_DECODER.decode(localHeader) + TEXT_DECODER.decode(embeddedPdf);
583
585
  const pdfTagIndex = findEmbeddedDataTagIndex(embeddedPdfText);
584
586
  if (pdfTagIndex == -1) {
585
- dropUnhiddenFace(options, "embeddedPdf");
587
+ dropUnhiddenFace(options, "embeddedPdf", EMBEDDED_PDF_LABEL);
586
588
  pdfEntry = undefined;
587
589
  } else {
588
590
  const [pdfStartTag, pdfEndTag] = EMBEDDED_DATA_TAGS[pdfTagIndex];
@@ -704,9 +706,9 @@ function getEmbeddedImageData(embeddedImage) {
704
706
  return embeddedImage.slice(PNG_SIGNATURE_LENGTH + PNG_IHDR_LENGTH, embeddedImage.length - PNG_IEND_LENGTH);
705
707
  }
706
708
 
707
- function dropUnhiddenFace(options, name) {
709
+ function dropUnhiddenFace(options, name, label) {
708
710
  delete options[name];
709
- console.warn(UNHIDDEN_FACE_WARNING_MESSAGE, name); // eslint-disable-line no-console
711
+ console.warn(UNHIDDEN_FACE_WARNING_MESSAGE, label); // eslint-disable-line no-console
710
712
  }
711
713
 
712
714
  async function writeData(writable, array) {