mirror of
https://github.com/jacobtread/obsidian-timekeep.git
synced 2026-07-22 10:10:27 +00:00
80 lines
2.7 KiB
Diff
80 lines
2.7 KiB
Diff
diff --git a/build/pdfmake.js b/build/pdfmake.js
|
|
index 97e3b9b54d6a885a0d9c73c03dec538c0d5a8b7d..4322c19c79e9a15ca7f4f70c8f03dc51583a01da 100644
|
|
--- a/build/pdfmake.js
|
|
+++ b/build/pdfmake.js
|
|
@@ -8517,56 +8517,6 @@ function calculatePageHeight(page, margins) {
|
|
// EXTERNAL MODULE: ./src/virtual-fs.js
|
|
var virtual_fs = __webpack_require__(6811);
|
|
;// ./src/URLResolver.js
|
|
-const MAX_REDIRECTS = 30;
|
|
-
|
|
-/**
|
|
- * @param {string} url
|
|
- * @param {object} headers
|
|
- * @param {(url: string) => boolean} urlAccessPolicy
|
|
- * @returns {Promise<Response>}
|
|
- */
|
|
-async function fetchUrl(url, headers, urlAccessPolicy) {
|
|
- if (headers === void 0) {
|
|
- headers = {};
|
|
- }
|
|
- for (let i = 0; i <= MAX_REDIRECTS; i++) {
|
|
- if (typeof urlAccessPolicy !== 'undefined' && urlAccessPolicy(url) !== true) {
|
|
- throw new Error(`Access to URL denied by resource access policy: ${url}`);
|
|
- }
|
|
- try {
|
|
- let response = await fetch(url, {
|
|
- headers,
|
|
- redirect: 'manual'
|
|
- });
|
|
-
|
|
- // redirect url
|
|
- if (response.status >= 300 && response.status < 400) {
|
|
- let location = response.headers.get('location');
|
|
- if (!location) {
|
|
- throw new Error('Redirect response missing Location header');
|
|
- }
|
|
- url = new URL(location, url).href;
|
|
- continue;
|
|
- }
|
|
-
|
|
- // browsers do not support redirect: 'manual'
|
|
- if (response.type === 'opaqueredirect') {
|
|
- response = await fetch(url, {
|
|
- headers
|
|
- });
|
|
- }
|
|
- if (!response.ok) {
|
|
- throw new Error(`Failed to fetch (status code: ${response.status})`);
|
|
- }
|
|
- return response;
|
|
- } catch (error) {
|
|
- throw new Error(`Network request failed (url: "${url}", error: ${error.message})`, {
|
|
- cause: error
|
|
- });
|
|
- }
|
|
- }
|
|
- throw new Error(`Network request failed (url: "${url}", error: Too many redirects)`);
|
|
-}
|
|
class URLResolver {
|
|
constructor(fs) {
|
|
this.fs = fs;
|
|
@@ -8589,16 +8539,8 @@ class URLResolver {
|
|
if (this.fs.existsSync(url)) {
|
|
return; // url was downloaded earlier
|
|
}
|
|
- const response = await fetchUrl(url, headers, this.urlAccessPolicy);
|
|
-
|
|
- // validate access policy on redirected url (in browsers, only the final URL is validated)
|
|
- if (response.redirected) {
|
|
- if (typeof this.urlAccessPolicy !== 'undefined' && this.urlAccessPolicy(response.url) !== true) {
|
|
- throw new Error(`Access to URL denied by resource access policy: ${response.url}`);
|
|
- }
|
|
- }
|
|
- const buffer = await response.arrayBuffer();
|
|
- this.fs.writeFileSync(url, buffer);
|
|
+
|
|
+ throw new Error("External resource loading disallowed by obsidian-timekeep")
|
|
}
|
|
// else cannot be resolved
|
|
};
|