diff --git a/src/languages/en.js b/src/languages/en.js index 98f254b2321a..0d4066dc3275 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -944,7 +944,8 @@ export default { editor: { nameInputLabel: 'Name', nameInputHelpText: 'This is the name you will see on your workspace.', - nameIsRequiredError: 'You need to define a name for your workspace', + nameIsRequiredError: 'You need to define a name for your workspace.', + nameHasHtml: 'HTML tags are not allowed in workspace names.', currencyInputLabel: 'Default currency', currencyInputHelpText: 'All expenses on this workspace will be converted to this currency.', save: 'Save', diff --git a/src/languages/es.js b/src/languages/es.js index eeb46d702bd5..7d51150d6f7e 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -947,6 +947,7 @@ export default { nameInputLabel: 'Nombre', nameInputHelpText: 'Este es el nombre que verás en tu espacio de trabajo.', nameIsRequiredError: 'Debes definir un nombre para tu espacio de trabajo.', + nameHasHtml: 'Las etiquetas HTML no están permitidas en los nombres de los espacios de trabajo.', currencyInputLabel: 'Moneda por defecto', currencyInputHelpText: 'Todas los gastos en este espacio de trabajo serán convertidos a esta moneda.', save: 'Guardar', diff --git a/src/pages/workspace/WorkspaceSettingsPage.js b/src/pages/workspace/WorkspaceSettingsPage.js index ad858f9ab29f..b67e774fbcb4 100644 --- a/src/pages/workspace/WorkspaceSettingsPage.js +++ b/src/pages/workspace/WorkspaceSettingsPage.js @@ -35,8 +35,8 @@ class WorkspaceSettingsPage extends React.Component { constructor(props) { super(props); - this.submit = this.submit.bind(this); this.getCurrencyItems = this.getCurrencyItems.bind(this); + this.submit = this.submit.bind(this); this.validate = this.validate.bind(this); } @@ -55,17 +55,24 @@ class WorkspaceSettingsPage extends React.Component { if (this.props.policy.isPolicyUpdating) { return; } - const name = values.name.trim(); const outputCurrency = values.currency; - Policy.updateGeneralSettings(this.props.policy.id, name, outputCurrency); + Policy.updateGeneralSettings(this.props.policy.id, values.name, outputCurrency); Keyboard.dismiss(); } validate(values) { const errors = {}; - if (!values.name || !values.name.trim().length) { + const name = values.name.trim(); + + // Searches for anything that looks like an html tag "< >"" + if (name.search(/<(.|\n)*?>/g) !== -1) { + errors.name = this.props.translate('workspace.editor.nameHasHtml'); + } + + if (!name || !name.length) { errors.name = this.props.translate('workspace.editor.nameIsRequiredError'); } + return errors; }