Skip to content

Commit

Permalink
Copy and patch paged.js
Browse files Browse the repository at this point in the history
We do not use npm to install pagedjs because currently it contains several critical vulnerabilities.
See: https://gitlab.pagedmedia.org/tools/pagedjs/merge_requests/44
  • Loading branch information
ggrossetie committed Jan 24, 2019
1 parent 5f851b2 commit f8b59d7
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2,719 deletions.
Binary file modified examples/document/document.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion examples/document/templates/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = (node) => `<!DOCTYPE html>
<meta charset="UTF-8">
<link href="./asciidoctor.css" rel="stylesheet">
<link href="./document.css" rel="stylesheet">
<script src="../../lib/paged.polyfill.js"></script>
<script src="../../lib/paged-0.1.30.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body class="article">
Expand Down
8 changes: 7 additions & 1 deletion lib/paged.polyfill.js → lib/paged-0.1.30.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// This file was copied from the pagedjs package[1] version 0.1.30: node_modules/pagedjs/dist/paged.polyfill.js
// Include a critical fix when loading files from the file:// protocol with Chrome (see line 23942).
//
// [1] https://www.npmjs.com/package/pagedjs
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
Expand Down Expand Up @@ -23932,7 +23936,9 @@ img {
request.withCredentials = options.credentials=='include';

request.onload = () => {
const status = request.status === 0 && url.startsWith('file://') ? 200 : request.status;
// Workaround for Chrome where status code is equals to 0.
// Upstream merge request: https://gitlab.pagedmedia.org/tools/pagedjs/merge_requests/43
const status = request.status === 0 && url.startsWith('file://') ? 200 : request.status;
resolve(new Response(request.responseText, {status}));
};

Expand Down
Loading

0 comments on commit f8b59d7

Please sign in to comment.