Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add checks to make sure Place, Domain, and User names are not set to …
…zero length strings.
  • Loading branch information
Misterblue committed Jun 15, 2021
1 parent a0b63aa commit 5f5a7f1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Entities/AccountFields.ts
Expand Up @@ -103,7 +103,7 @@ export const accountFields: { [key: string]: FieldDefn } = {
set_permissions: [ Perm.OWNER, Perm.ADMIN ],
validate: async (pField: FieldDefn, pEntity: Entity, pVal: any): Promise<ValidateResponse> => {
let validity: ValidateResponse;
if (typeof(pVal) === 'string') {
if (typeof(pVal) === 'string' && pVal.length > 0) {
// Check email for sanity
// Old style check which doesn't cover all the RFC complient email addresses possible
// if (/^[A-Za-z0-9+\-_\.]+@[A-Za-z0-9-\.]+$/.test(pVal)) {
Expand Down
4 changes: 2 additions & 2 deletions src/Entities/DomainFields.ts
Expand Up @@ -69,7 +69,7 @@ export const DomainFields: { [key: string]: FieldDefn } = {
set_permissions: [ Perm.DOMAIN, Perm.SPONSOR, Perm.ADMIN ],
validate: async (pField: FieldDefn, pEntity: Entity, pVal: any): Promise<ValidateResponse> => {
let validity: ValidateResponse;
if (typeof(pVal) === 'string' && (pVal as string).length > 0) {
if (typeof(pVal) === 'string' && pVal.length > 0) {
if (pVal.length <= Config['metaverse-server']['max-name-length']) {
if( /^[A-Za-z][A-Za-z0-9+\-_\.]*$/.test(pVal) ) {
validity = { valid: true };
Expand Down Expand Up @@ -112,7 +112,7 @@ export const DomainFields: { [key: string]: FieldDefn } = {
set_permissions: [ Perm.DOMAIN, Perm.SPONSOR, Perm.ADMIN ],
validate: async (pField: FieldDefn, pEntity: Entity, pVal: any): Promise<ValidateResponse> => {
let validity: ValidateResponse;
if (typeof(pVal) === 'string' && (pVal as string).length > 0) {
if (typeof(pVal) === 'string' && pVal.length > 0) {
if (/^[A-Za-z][A-Za-z0-9+\-_\.]*$/.test(pVal)) {
validity = { valid: true };
}
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/PlaceFields.ts
Expand Up @@ -56,7 +56,7 @@ export const placeFields: { [key: string]: FieldDefn } = {
validate: async (pField: FieldDefn, pEntity: Entity, pVal: any): Promise<ValidateResponse> => {
// Verify that the placename is unique
let validity: ValidateResponse;
if (typeof(pVal) === 'string') {
if (typeof(pVal) === 'string' && pVal.length > 0) {
if (pVal.length <= Config['metaverse-server']['max-name-length']) {
const maybePlace = await Places.getPlaceWithName(pVal);
// If no other place with this name or we're setting our own name
Expand Down

0 comments on commit 5f5a7f1

Please sign in to comment.