Skip to content

Commit 6509fdb

Browse files
committed
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.
1 parent 586e858 commit 6509fdb

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/display/fetch_stream.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* limitations under the License.
1414
*/
1515

16-
import { AbortException, warn } from "../shared/util.js";
16+
import { AbortException, assert, warn } from "../shared/util.js";
1717
import {
1818
BasePDFStream,
1919
BasePDFStreamRangeReader,
@@ -69,8 +69,11 @@ class PDFFetchStream extends BasePDFStream {
6969
super(source, PDFFetchStreamReader, PDFFetchStreamRangeReader);
7070
const { httpHeaders, url } = source;
7171

72-
this.isHttp = /https?:/.test(url.protocol);
73-
this.headers = createHeaders(this.isHttp, httpHeaders);
72+
assert(
73+
/https?:/.test(url.protocol),
74+
"PDFFetchStream only supports http(s):// URLs."
75+
);
76+
this.headers = createHeaders(/* isHttp = */ true, httpHeaders);
7477
}
7578
}
7679

@@ -108,7 +111,7 @@ class PDFFetchStreamReader extends BasePDFStreamReader {
108111
const { allowRangeRequests, suggestedLength } =
109112
validateRangeRequestCapabilities({
110113
responseHeaders,
111-
isHttp: stream.isHttp,
114+
isHttp: true,
112115
rangeChunkSize,
113116
disableRange,
114117
});

0 commit comments

Comments
 (0)