remove edge case arg injection in formatYunohostArguments

This commit is contained in:
axolotle 2022-03-01 15:49:10 +01:00
parent f2cb4fa0a0
commit 9b57063572
2 changed files with 14 additions and 14 deletions

View file

@ -259,21 +259,12 @@ export function formatYunoHostArgument (arg) {
* @param {String} name - (temp) an app name to build a label field in case of manifest install args * @param {String} name - (temp) an app name to build a label field in case of manifest install args
* @return {Object} an object containing all parsed values to be used in vue views. * @return {Object} an object containing all parsed values to be used in vue views.
*/ */
export function formatYunoHostArguments (args, name = null) { export function formatYunoHostArguments (args) {
const form = {} const form = {}
const fields = {} const fields = {}
const validations = {} const validations = {}
const errors = {} const errors = {}
// FIXME yunohost should add the label field by default
if (name) {
args.unshift({
ask: i18n.t('label_for_manifestname', { name }),
default: name,
name: 'label'
})
}
for (const arg of args) { for (const arg of args) {
const { value, field, validation, error } = formatYunoHostArgument(arg) const { value, field, validation, error } = formatYunoHostArgument(arg)
fields[arg.name] = field fields[arg.name] = field

View file

@ -92,10 +92,19 @@ export default {
manifest.multi_instance = this.$i18n.t(manifest.multi_instance ? 'yes' : 'no') manifest.multi_instance = this.$i18n.t(manifest.multi_instance ? 'yes' : 'no')
this.infos = Object.fromEntries(infosKeys.map(key => [key, manifest[key]])) this.infos = Object.fromEntries(infosKeys.map(key => [key, manifest[key]]))
const { form, fields, validations, errors } = formatYunoHostArguments( // FIXME yunohost should add the label field by default
manifest.arguments.install, manifest.arguments.install.unshift({
manifest.name ask: this.$t('label_for_manifestname', { name: manifest.name }),
) default: manifest.name,
name: 'label'
})
const {
form,
fields,
validations,
errors
} = formatYunoHostArguments(manifest.arguments.install)
this.fields = fields this.fields = fields
this.form = form this.form = form