Skip to content

Commit

Permalink
Force isEvalSupported to true
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmaj committed May 7, 2024
1 parent 174a259 commit 9ab31ab
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/react-pdf/src/Document.tsx
Expand Up @@ -187,6 +187,8 @@ export type DocumentProps = {
*
* **Note**: Make sure to define options object outside of your React component, and use `useMemo` if you can't.
*
* **Note**: `isEvalSupported` is forced to `false` to prevent [arbitrary JavaScript execution upon opening a malicious PDF file](https://github.com/mozilla/pdf.js/security/advisories/GHSA-wgrm-67xf-hhpq).
*
* @example { cMapUrl: '/cmaps/' }
*/
options?: Options;
Expand Down Expand Up @@ -503,12 +505,12 @@ const Document = forwardRef(function Document(
return;
}

const documentInitParams = options
? {
...source,
...options,
}
: source;
const optionsWithModifiedIsEvalSupported: Options = { ...options, isEvalSupported: true };

const documentInitParams: Source = {
...source,
...optionsWithModifiedIsEvalSupported,
};

const destroyable = pdfjs.getDocument(documentInitParams);
if (onLoadProgress) {
Expand Down

0 comments on commit 9ab31ab

Please sign in to comment.