mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-08-03 04:47:21 +02: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.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { AbortException, warn } from "../shared/util.js";
|
import { AbortException, assert, warn } from "../shared/util.js";
|
||||||
import {
|
import {
|
||||||
BasePDFStream,
|
BasePDFStream,
|
||||||
BasePDFStreamRangeReader,
|
BasePDFStreamRangeReader,
|
||||||
@ -69,8 +69,11 @@ class PDFFetchStream extends BasePDFStream {
|
|||||||
super(source, PDFFetchStreamReader, PDFFetchStreamRangeReader);
|
super(source, PDFFetchStreamReader, PDFFetchStreamRangeReader);
|
||||||
const { httpHeaders, url } = source;
|
const { httpHeaders, url } = source;
|
||||||
|
|
||||||
this.isHttp = /https?:/.test(url.protocol);
|
assert(
|
||||||
this.headers = createHeaders(this.isHttp, httpHeaders);
|
/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 } =
|
const { allowRangeRequests, suggestedLength } =
|
||||||
validateRangeRequestCapabilities({
|
validateRangeRequestCapabilities({
|
||||||
responseHeaders,
|
responseHeaders,
|
||||||
isHttp: stream.isHttp,
|
isHttp: true,
|
||||||
rangeChunkSize,
|
rangeChunkSize,
|
||||||
disableRange,
|
disableRange,
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user