Skip to content

Commit

Permalink
Merge pull request #310 from smartdevicelink/bugfix/vehicle_data_inva…
Browse files Browse the repository at this point in the history
…lid_chars

Prevent making custom vehicle data with invalid characters
  • Loading branch information
renonick87 authored Oct 24, 2022
2 parents c79c9b8 + 6c13222 commit 76949f9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/components/common/VehicleDataItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
<div class="form-group row">
<label class="col-sm-2 col-form-label">{{ propsDisplay[propName].display.toUpperCase() }}</label>
<div class="col-sm-10">
<input v-model="item[propName]" :disabled="fieldsDisabled || (level === 1 && item.id)" class="form-control">
<input v-model="item[propName]" :disabled="fieldsDisabled || (level === 1 && item.id)" class="form-control"
@input="updateNameOrKey(propName, $event.target.value)">
</div>
<p v-if="findCommonParams(item[propName]) === 'CUSTOM'">
<br>A parent or top level vehicle data item with this name already exists! By saving, you will overwrite the previously existing vehicle data.
Expand Down Expand Up @@ -55,7 +56,8 @@
<div class="form-group row">
<label class="col-sm-2 col-form-label">{{ propsDisplay[propName].display.toUpperCase() }}</label>
<div class="col-sm-10">
<input v-model="item[propName]" :disabled="fieldsDisabled" class="form-control">
<input v-model="item[propName]" :disabled="fieldsDisabled" class="form-control"
@input="updateNameOrKey(propName, $event.target.value)">
</div>
</div>
</template>
Expand Down Expand Up @@ -170,6 +172,12 @@
}
this.item[propName] = Math.max(0, Math.round(val));
},
updateNameOrKey: function (propName, val) {
// Checks for the invalid characters "!@#$%^&*", and whitespace characters that would be rejected by SDL Core
if (/[!@#$%^&*\s]/g.test(val)) {
return this.item[propName] = null;
}
},
updateIntegerNumber: function (propName, val) {
if (val === "-") {
return val;
Expand Down

0 comments on commit 76949f9

Please sign in to comment.