mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-19 08:33:23 +02:00
only accept http(s) and data uris in zip tool
This commit is contained in:
@@ -874,8 +874,12 @@ export const createServer = () => {
|
|||||||
const { files, outputType } = ZipResourcesInputSchema.parse(args);
|
const { files, outputType } = ZipResourcesInputSchema.parse(args);
|
||||||
const zip = new JSZip();
|
const zip = new JSZip();
|
||||||
|
|
||||||
for (const [fileName, fileUrl] of Object.entries(files)) {
|
for (const [fileName, fileUrlString] of Object.entries(files)) {
|
||||||
try {
|
try {
|
||||||
|
const fileUrl = new URL(fileUrlString);
|
||||||
|
if (fileUrl.protocol !== 'http:' && fileUrl.protocol !== 'https:' && fileUrl.protocol !== 'data:') {
|
||||||
|
throw new Error(`Unsupported URL protocol for ${fileUrlString}. Only http, https, and data URLs are supported.`);
|
||||||
|
}
|
||||||
const response = await fetch(fileUrl);
|
const response = await fetch(fileUrl);
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`Failed to fetch ${fileUrl}: ${response.statusText}`);
|
throw new Error(`Failed to fetch ${fileUrl}: ${response.statusText}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user