mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-02-08 00:21:11 +01:00
Assert that PDFFetchStream is only used with HTTP(S) URLs
Note how `getDocument` checks the protocol, via the `isValidFetchUrl` helper, before attempting to use the `PDFFetchStream` implementation.
This commit is contained in:
parent
586e85888b
commit
6509fdb1d6
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { AbortException, warn } from "../shared/util.js";
|
||||
import { AbortException, assert, warn } from "../shared/util.js";
|
||||
import {
|
||||
BasePDFStream,
|
||||
BasePDFStreamRangeReader,
|
||||
@ -69,8 +69,11 @@ class PDFFetchStream extends BasePDFStream {
|
||||
super(source, PDFFetchStreamReader, PDFFetchStreamRangeReader);
|
||||
const { httpHeaders, url } = source;
|
||||
|
||||
this.isHttp = /https?:/.test(url.protocol);
|
||||
this.headers = createHeaders(this.isHttp, httpHeaders);
|
||||
assert(
|
||||
/https?:/.test(url.protocol),
|
||||
"PDFFetchStream only supports http(s):// URLs."
|
||||
);
|
||||
this.headers = createHeaders(/* isHttp = */ true, httpHeaders);
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,7 +111,7 @@ class PDFFetchStreamReader extends BasePDFStreamReader {
|
||||
const { allowRangeRequests, suggestedLength } =
|
||||
validateRangeRequestCapabilities({
|
||||
responseHeaders,
|
||||
isHttp: stream.isHttp,
|
||||
isHttp: true,
|
||||
rangeChunkSize,
|
||||
disableRange,
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user