Compare commits

..

No commits in common. "a40bf371843599e7b2d30dc672cfbe09b24965df" and "efc5c3c2314840098551c325cd7e31d60ef3bd53" have entirely different histories.

16 changed files with 16 additions and 66 deletions

View File

@ -14,7 +14,7 @@ get involved, visit:
+ [Issue Reporting Guide](https://github.com/mozilla/pdf.js/blob/master/.github/CONTRIBUTING.md)
+ [Code Contribution Guide](https://github.com/mozilla/pdf.js/wiki/Contributing)
+ [Frequently Asked Questions](https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions)
+ [Good Beginner Bugs](https://github.com/mozilla/pdf.js/issues?q=is%3Aissue%20state%3Aopen%20label%3Agood-beginner-bug)
+ [Good Beginner Bugs](https://github.com/mozilla/pdf.js/issues?direction=desc&labels=good-beginner-bug&page=1&sort=created&state=open)
+ [Projects](https://github.com/mozilla/pdf.js/projects)
Feel free to stop by our [Matrix room](https://chat.mozilla.org/#/room/#pdfjs:mozilla.org) for questions or guidance.

View File

@ -46,7 +46,6 @@ limitations under the License.
}
var scheme = url.slice(0, schemeIndex).toLowerCase();
if (schemes.includes(scheme)) {
// NOTE: We cannot use the `updateUrlHash` function in this context.
url = url.split("#", 1)[0];
if (url.charAt(schemeIndex) === ":") {
url = encodeURIComponent(url);

View File

@ -2315,7 +2315,7 @@ function packageJson() {
url: `git+${DIST_GIT_URL}`,
},
engines: {
node: ">=20.16.0 || >=22.3.0",
node: ">=20.16.0",
},
scripts: {},
};

2
package-lock.json generated
View File

@ -63,7 +63,7 @@
"yargs": "^17.7.2"
},
"engines": {
"node": ">=20.16.0 || >=22.3.0"
"node": ">=20.16.0"
}
},
"node_modules/@aashutoshrathi/word-wrap": {

View File

@ -62,7 +62,7 @@
"url": "git://github.com/mozilla/pdf.js.git"
},
"engines": {
"node": ">=20.16.0 || >=22.3.0"
"node": ">=20.16.0"
},
"license": "Apache-2.0"
}

View File

@ -1607,9 +1607,6 @@ class Catalog {
// NOTE: the destination is relative to the *remote* document.
const remoteDest = fetchRemoteDest(action);
if (remoteDest && typeof url === "string") {
// NOTE: We don't use the `updateUrlHash` function here, since
// the `createValidAbsoluteUrl` function (see below) already
// handles parsing and validation of the final URL.
url = /* baseUrl = */ url.split("#", 1)[0] + "#" + remoteDest;
}
// The 'NewWindow' property, equal to `LinkTarget.BLANK`.

View File

@ -14,7 +14,7 @@
*/
import { getRGB, isDataScheme, SVG_NS } from "./display_utils.js";
import { unreachable, updateUrlHash, Util, warn } from "../shared/util.js";
import { unreachable, Util, warn } from "../shared/util.js";
class BaseFilterFactory {
constructor() {
@ -143,7 +143,7 @@ class DOMFilterFactory extends BaseFilterFactory {
if (isDataScheme(url)) {
warn('#createUrl: ignore "data:"-URL for performance reasons.');
} else {
this.#baseUrl = updateUrlHash(url, "");
this.#baseUrl = url.split("#", 1)[0];
}
}
}

View File

@ -40,7 +40,6 @@ import {
PermissionFlag,
ResponseException,
shadow,
updateUrlHash,
Util,
VerbosityLevel,
} from "./shared/util.js";
@ -141,7 +140,6 @@ globalThis.pdfjsLib = {
SupportedImageMimeTypes,
TextLayer,
TouchManager,
updateUrlHash,
Util,
VerbosityLevel,
version,
@ -195,7 +193,6 @@ export {
SupportedImageMimeTypes,
TextLayer,
TouchManager,
updateUrlHash,
Util,
VerbosityLevel,
version,

View File

@ -445,28 +445,6 @@ function createValidAbsoluteUrl(url, baseUrl = null, options = null) {
return _isValidProtocol(absoluteUrl) ? absoluteUrl : null;
}
/**
* Remove, or replace, the hash property of the URL.
*
* @param {URL|string} url - The absolute, or relative, URL.
* @param {string} hash - The hash property (use an empty string to remove it).
* @param {boolean} [allowRel] - Allow relative URLs.
* @returns {string} The resulting URL string.
*/
function updateUrlHash(url, hash, allowRel = false) {
const res = URL.parse(url);
if (res) {
res.hash = hash;
return res.href;
}
// Support well-formed relative URLs, necessary for `web/app.js` in GENERIC
// builds, by optionally falling back to string parsing.
if (allowRel && createValidAbsoluteUrl(url, "http://example.com")) {
return url.split("#", 1)[0] + `${hash ? `#${hash}` : ""}`;
}
return "";
}
function shadow(obj, prop, value, nonSerializable = false) {
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
assert(
@ -1341,7 +1319,6 @@ export {
toHexUtil,
UnknownErrorException,
unreachable,
updateUrlHash,
utf8StringToString,
Util,
VerbosityLevel,

View File

@ -31,7 +31,6 @@ import {
PermissionFlag,
ResponseException,
shadow,
updateUrlHash,
Util,
VerbosityLevel,
} from "../../src/shared/util.js";
@ -118,7 +117,6 @@ const expectedAPI = Object.freeze({
SupportedImageMimeTypes,
TextLayer,
TouchManager,
updateUrlHash,
Util,
VerbosityLevel,
version,

View File

@ -57,7 +57,6 @@ import {
shadow,
stopEvent,
TouchManager,
updateUrlHash,
version,
} from "pdfjs-lib";
import { AppOptions, OptionKind } from "./app_options.js";
@ -944,18 +943,10 @@ const PDFViewerApplication = {
setTitleUsingUrl(url = "", downloadUrl = null) {
this.url = url;
this.baseUrl =
typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")
? updateUrlHash(url, "", /* allowRel = */ true)
: updateUrlHash(url, "");
this.baseUrl = url.split("#", 1)[0];
if (downloadUrl) {
this._downloadUrl =
// eslint-disable-next-line no-nested-ternary
downloadUrl === url
? this.baseUrl
: typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")
? updateUrlHash(downloadUrl, "", /* allowRel = */ true)
: updateUrlHash(downloadUrl, "");
downloadUrl === url ? this.baseUrl : downloadUrl.split("#", 1)[0];
}
if (isDataScheme(url)) {
this._hideViewBookmark();
@ -1318,7 +1309,7 @@ const PDFViewerApplication = {
this.secondaryToolbar?.setPagesCount(pdfDocument.numPages);
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("CHROME")) {
const baseUrl = updateUrlHash(location, "");
const baseUrl = location.href.split("#", 1)[0];
// Ignore "data:"-URLs for performance reasons, even though it may cause
// internal links to not work perfectly in all cases (see bug 1803050).
this.pdfLinkService.setDocument(

View File

@ -393,13 +393,7 @@ const defaultOptions = {
},
docBaseUrl: {
/** @type {string} */
value:
typeof PDFJSDev === "undefined"
? // NOTE: We cannot use the `updateUrlHash` function here, because of
// the default preferences generation (see `gulpfile.mjs`).
// However, the following line is *only* used in development mode.
document.URL.split("#", 1)[0]
: "",
value: typeof PDFJSDev === "undefined" ? document.URL.split("#", 1)[0] : "",
kind: OptionKind.API,
},
enableHWA: {

View File

@ -17,7 +17,7 @@ import { getPdfFilenameFromUrl } from "pdfjs-lib";
async function docProperties(pdfDocument) {
const url = "",
baseUrl = "";
baseUrl = url.split("#", 1)[0];
const { info, metadata, contentDispositionFilename, contentLength } =
await pdfDocument.getMetadata();

View File

@ -17,7 +17,6 @@
/** @typedef {import("./interfaces").IPDFLinkService} IPDFLinkService */
import { isValidRotation, parseQueryString } from "./ui_utils.js";
import { updateUrlHash } from "pdfjs-lib";
import { waitOnEventOrTimeout } from "./event_utils.js";
// Heuristic value used when force-resetting `this._blockHashChange`.
@ -384,9 +383,10 @@ class PDFHistory {
let newUrl;
if (this._updateUrl && destination?.hash) {
const { href, protocol } = document.location;
if (protocol !== "file:") {
newUrl = updateUrlHash(href, destination.hash);
const baseUrl = document.location.href.split("#", 1)[0];
// Prevent errors in Firefox.
if (!baseUrl.startsWith("file://")) {
newUrl = `${baseUrl}#${destination.hash}`;
}
}
if (shouldReplace) {

View File

@ -32,7 +32,6 @@ import {
AnnotationEditorType,
AnnotationEditorUIManager,
AnnotationMode,
MathClamp,
PermissionFlag,
PixelsPerInch,
shadow,
@ -2295,7 +2294,7 @@ class PDFViewer {
newScale = round((newScale * delta).toFixed(2) * 10) / 10;
} while (--steps > 0);
}
newScale = MathClamp(newScale, MIN_SCALE, MAX_SCALE);
newScale = Math.max(MIN_SCALE, Math.min(MAX_SCALE, newScale));
this.#setScale(newScale, { noScroll: false, drawingDelay, origin });
}

View File

@ -60,7 +60,6 @@ const {
SupportedImageMimeTypes,
TextLayer,
TouchManager,
updateUrlHash,
Util,
VerbosityLevel,
version,
@ -114,7 +113,6 @@ export {
SupportedImageMimeTypes,
TextLayer,
TouchManager,
updateUrlHash,
Util,
VerbosityLevel,
version,