Sanitize model names in server (#3970)
This commit is contained in:
committed by
GitHub
parent
314f4c6527
commit
967eec9db4
@@ -22,5 +22,6 @@ export function sanitizeModelName(name: string): string {
|
||||
return name
|
||||
.split('/')
|
||||
.map((part) => part.trim())
|
||||
.filter((part) => part.length > 0)
|
||||
.join('/')
|
||||
}
|
||||
|
||||
@@ -310,6 +310,17 @@ export = {
|
||||
ctx.resourceAccessRules
|
||||
)
|
||||
const projectDB = await getProjectDbClient({ projectId: args.input.projectId })
|
||||
|
||||
// Sanitize model name by trimming spaces around slashes
|
||||
const sanitizedInput = {
|
||||
...args.input,
|
||||
name: args.input.name
|
||||
.split('/')
|
||||
.map((part) => part.trim())
|
||||
.filter((part) => part.length > 0)
|
||||
.join('/')
|
||||
}
|
||||
|
||||
const createBranchAndNotify = createBranchAndNotifyFactory({
|
||||
getStreamBranchByName: getStreamBranchByNameFactory({ db: projectDB }),
|
||||
createBranch: createBranchFactory({ db: projectDB }),
|
||||
@@ -318,7 +329,7 @@ export = {
|
||||
publish
|
||||
})
|
||||
})
|
||||
return await createBranchAndNotify(args.input, ctx.userId!)
|
||||
return await createBranchAndNotify(sanitizedInput, ctx.userId!)
|
||||
},
|
||||
async update(_parent, args, ctx) {
|
||||
await authorizeResolver(
|
||||
|
||||
Reference in New Issue
Block a user