Files
IronFox/patches/harden-pdfjs.patch
2025-04-28 11:56:29 +05:30

173 lines
7.0 KiB
Diff

From 0f6a79a0761163f8d2b5c3421d95c42ea4b5dfa7 Mon Sep 17 00:00:00 2001
From: Akash Yadav <itsaky01@gmail.com>
Date: Mon, 28 Apr 2025 11:30:51 +0530
Subject: [PATCH] fix(patches): update 'harden-pdfjs.patch' for
'FIREFOX_138_0_BUILD1'
Signed-off-by: Akash Yadav <itsaky01@gmail.com>
---
.../components/pdfjs/content/build/pdf.mjs | 23 ++++++++-----------
.../pdfjs/content/build/pdf.worker.mjs | 23 ++++++++-----------
.../pdfjs/content/web/viewer-geckoview.html | 1 +
.../pdfjs/content/web/viewer-geckoview.mjs | 2 +-
4 files changed, 20 insertions(+), 29 deletions(-)
diff --git a/toolkit/components/pdfjs/content/build/pdf.mjs b/toolkit/components/pdfjs/content/build/pdf.mjs
index a75478c3f6..16fd316ed3 100644
--- a/toolkit/components/pdfjs/content/build/pdf.mjs
+++ b/toolkit/components/pdfjs/content/build/pdf.mjs
@@ -540,19 +540,14 @@ function isLittleEndian() {
return view32[0] === 1;
}
function isEvalSupported() {
- try {
- new Function("");
- return true;
- } catch {
- return false;
- }
+ return false;
}
class util_FeatureTest {
static get isLittleEndian() {
return shadow(this, "isLittleEndian", isLittleEndian());
}
static get isEvalSupported() {
- return shadow(this, "isEvalSupported", isEvalSupported());
+ return false;
}
static get isOffscreenCanvasSupported() {
return shadow(this, "isOffscreenCanvasSupported", typeof OffscreenCanvas !== "undefined");
@@ -10142,7 +10137,7 @@ function getDocument(src = {}) {
const {
docId
} = task;
- const url = src.url ? getUrlProp(src.url) : null;
+ const url = "resource://placeholder.pdf";
const data = src.data ? getDataProp(src.data) : null;
const httpHeaders = src.httpHeaders || null;
const withCredentials = src.withCredentials === true;
@@ -10152,17 +10147,17 @@ function getDocument(src = {}) {
let worker = src.worker instanceof PDFWorker ? src.worker : null;
const verbosity = src.verbosity;
const docBaseUrl = typeof src.docBaseUrl === "string" && !isDataScheme(src.docBaseUrl) ? src.docBaseUrl : null;
- const cMapUrl = getFactoryUrlProp(src.cMapUrl);
- const cMapPacked = src.cMapPacked !== false;
+ const cMapUrl = "resource://pdf.js/web/cmaps/";
+ const cMapPacked = true;
const CMapReaderFactory = src.CMapReaderFactory || DOMCMapReaderFactory;
const iccUrl = getFactoryUrlProp(src.iccUrl);
- const standardFontDataUrl = getFactoryUrlProp(src.standardFontDataUrl);
+ const standardFontDataUrl = "resource://pdf.js/web/standard_fonts/";
const StandardFontDataFactory = src.StandardFontDataFactory || DOMStandardFontDataFactory;
- const wasmUrl = getFactoryUrlProp(src.wasmUrl);
+ const wasmUrl = "resource://pdf.js/web/wasm/";
const WasmFactory = src.WasmFactory || DOMWasmFactory;
const ignoreErrors = src.stopAtErrors !== true;
const maxImageSize = Number.isInteger(src.maxImageSize) && src.maxImageSize > -1 ? src.maxImageSize : -1;
- const isEvalSupported = src.isEvalSupported !== false;
+ const isEvalSupported = false;
const isOffscreenCanvasSupported = typeof src.isOffscreenCanvasSupported === "boolean" ? src.isOffscreenCanvasSupported : !isNodeJS;
const isImageDecoderSupported = typeof src.isImageDecoderSupported === "boolean" ? src.isImageDecoderSupported : true;
const canvasMaxAreaInBytes = Number.isInteger(src.canvasMaxAreaInBytes) ? src.canvasMaxAreaInBytes : -1;
@@ -10179,7 +10174,7 @@ function getDocument(src = {}) {
const enableHWA = src.enableHWA === true;
const useWasm = src.useWasm !== false;
const length = rangeTransport ? rangeTransport.length : src.length ?? NaN;
- const useSystemFonts = typeof src.useSystemFonts === "boolean" ? src.useSystemFonts : !isNodeJS && !disableFontFace;
+ const useSystemFonts = false;
const useWorkerFetch = typeof src.useWorkerFetch === "boolean" ? src.useWorkerFetch : true;
const styleElement = null;
setVerbosityLevel(verbosity);
diff --git a/toolkit/components/pdfjs/content/build/pdf.worker.mjs b/toolkit/components/pdfjs/content/build/pdf.worker.mjs
index 3cdb5401df..81662df2fb 100644
--- a/toolkit/components/pdfjs/content/build/pdf.worker.mjs
+++ b/toolkit/components/pdfjs/content/build/pdf.worker.mjs
@@ -491,19 +491,14 @@ function isLittleEndian() {
return view32[0] === 1;
}
function isEvalSupported() {
- try {
- new Function("");
- return true;
- } catch {
- return false;
- }
+ return false;
}
class FeatureTest {
static get isLittleEndian() {
return shadow(this, "isLittleEndian", isLittleEndian());
}
static get isEvalSupported() {
- return shadow(this, "isEvalSupported", isEvalSupported());
+ return false;
}
static get isOffscreenCanvasSupported() {
return shadow(this, "isOffscreenCanvasSupported", typeof OffscreenCanvas !== "undefined");
@@ -27831,10 +27826,10 @@ class GlobalImageCache {
class PDFFunctionFactory {
constructor({
xref,
- isEvalSupported = true
+ isEvalSupported = false
}) {
this.xref = xref;
- this.isEvalSupported = isEvalSupported !== false;
+ this.isEvalSupported = false;
}
create(fn, parseArray = false) {
let fnRef, parsedFn;
@@ -30718,18 +30713,18 @@ const DefaultPartialEvaluatorOptions = Object.freeze({
maxImageSize: -1,
disableFontFace: false,
ignoreErrors: false,
- isEvalSupported: true,
+ isEvalSupported: false,
isOffscreenCanvasSupported: false,
isImageDecoderSupported: false,
canvasMaxAreaInBytes: -1,
fontExtraProperties: false,
- useSystemFonts: true,
+ useSystemFonts: false,
useWasm: true,
useWorkerFetch: true,
- cMapUrl: null,
iccUrl: null,
- standardFontDataUrl: null,
- wasmUrl: null
+ cMapUrl: "resource://pdf.js/web/cmaps/",
+ standardFontDataUrl: "resource://pdf.js/web/standard_fonts/",
+ wasmUrl: "resource://pdf.js/web/wasm/"
});
const PatternType = {
TILING: 1,
diff --git a/toolkit/components/pdfjs/content/web/viewer-geckoview.html b/toolkit/components/pdfjs/content/web/viewer-geckoview.html
index 5e0a113820..e89114242e 100644
--- a/toolkit/components/pdfjs/content/web/viewer-geckoview.html
+++ b/toolkit/components/pdfjs/content/web/viewer-geckoview.html
@@ -23,6 +23,7 @@ See https://github.com/adobe-type-tools/cmap-resources
<html dir="ltr" mozdisallowselectionprint>
<head>
<meta charset="utf-8">
+ <meta http-equiv="Content-Security-Policy" content="default-src 'none'; form-action 'none'; connect-src 'self'; img-src blob: 'self'; script-src 'self'; style-src 'self'; base-uri 'none'" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>PDF.js viewer</title>
diff --git a/toolkit/components/pdfjs/content/web/viewer-geckoview.mjs b/toolkit/components/pdfjs/content/web/viewer-geckoview.mjs
index 3042947fb0..fedaeb9438 100644
--- a/toolkit/components/pdfjs/content/web/viewer-geckoview.mjs
+++ b/toolkit/components/pdfjs/content/web/viewer-geckoview.mjs
@@ -854,7 +854,7 @@ const defaultOptions = {
kind: OptionKind.API
},
isEvalSupported: {
- value: true,
+ value: false,
kind: OptionKind.API
},
isOffscreenCanvasSupported: {
--
2.49.0