mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-11 16:18:59 +08:00
fix: Restrict artifact name in order to fix a Gist API bug
This commit is contained in:
parent
b1d811e4c5
commit
8aed0665e3
6
backend/dist/cron-sync-artifacts.min.js
vendored
6
backend/dist/cron-sync-artifacts.min.js
vendored
File diff suppressed because one or more lines are too long
6
backend/dist/sub-store-parser.loon.min.js
vendored
6
backend/dist/sub-store-parser.loon.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sub-store",
|
||||
"version": "2.8.3",
|
||||
"version": "2.8.4",
|
||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
|
||||
"main": "src/main.js",
|
||||
"scripts": {
|
||||
|
@ -64,6 +64,17 @@ async function getArtifact(req, res) {
|
||||
|
||||
function createArtifact(req, res) {
|
||||
const artifact = req.body;
|
||||
if (!validateArtifactName(artifact.name)) {
|
||||
failed(
|
||||
res,
|
||||
new RequestInvalidError(
|
||||
'INVALID_ARTIFACT_NAME',
|
||||
`Artifact name ${artifact.name} is invalid.`,
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
$.info(`正在创建远程配置:${artifact.name}`);
|
||||
const allArtifacts = $.read(ARTIFACTS_KEY);
|
||||
if (findByName(allArtifacts, artifact.name)) {
|
||||
@ -92,6 +103,16 @@ function updateArtifact(req, res) {
|
||||
...artifact,
|
||||
...req.body,
|
||||
};
|
||||
if (!validateArtifactName(newArtifact.name)) {
|
||||
failed(
|
||||
res,
|
||||
new RequestInvalidError(
|
||||
'INVALID_ARTIFACT_NAME',
|
||||
`Artifact name ${newArtifact.name} is invalid.`,
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
updateByName(allArtifacts, oldName, newArtifact);
|
||||
$.write(allArtifacts, ARTIFACTS_KEY);
|
||||
success(res, newArtifact);
|
||||
@ -407,4 +428,8 @@ async function produceArtifact({ type, name, platform }) {
|
||||
}
|
||||
}
|
||||
|
||||
function validateArtifactName(name) {
|
||||
return /^[a-zA-Z0-9._-]*$/.test(name);
|
||||
}
|
||||
|
||||
export { syncToGist, produceArtifact };
|
||||
|
6
backend/sub-store.min.js
vendored
6
backend/sub-store.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user