BOOL IsSafeStr(char *str) { UINT i, len; if (str == NULL) { return FALSE; } len = strlen(str); for (i = 0;i < len;i++) { if (IsSafeChar(str[i]) == FALSE) { return FALSE; } } if (str[0] == ' ') { return FALSE; } if (len != 0) { if (str[len - 1] == ' ') { return FALSE; } } return TRUE; }
// Check whether the string is safe bool IsSafeStr(char *str) { UINT i, len; // Validate arguments if (str == NULL) { return false; } len = StrLen(str); for (i = 0;i < len;i++) { if (IsSafeChar(str[i]) == false) { return false; } } if (str[0] == ' ') { return false; } if (len != 0) { if (str[len - 1] == ' ') { return false; } } return true; }
// Replace the unsafe characters void EnSafeStr(char *str, char replace) { if (str == NULL) { return; } while(*str != '\0') { if(IsSafeChar(*str) == false) { *str = replace; } str++; } }
// Check the name is valid for account name bool IsUserName(char *name) { UINT i, len; char tmp[MAX_SIZE]; // Validate arguments if (name == NULL) { return false; } StrCpy(tmp, sizeof(tmp), name); name = tmp; Trim(name); len = StrLen(name); if (len == 0) { return false; } if (StrCmpi(name, "*") == 0) { return true; } for (i = 0; i < len; i++) { if (IsSafeChar(name[i]) == false && name[i] != '@') { return false; } } if (StrCmpi(name, LINK_USER_NAME) == 0) { return false; } if (StartWith(name, L3_USERNAME)) { return false; } if (StrCmpi(name, LINK_USER_NAME_PRINT) == 0) { return false; } if (StrCmpi(name, SNAT_USER_NAME) == 0) { return false; } if (StrCmpi(name, SNAT_USER_NAME_PRINT) == 0) { return false; } if (StrCmpi(name, BRIDGE_USER_NAME) == 0) { return false; } if (StrCmpi(name, BRIDGE_USER_NAME_PRINT) == 0) { return false; } if (StrCmpi(name, ADMINISTRATOR_USERNAME) == 0) { return false; } return true; }