Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Modified the regular expression for name checks to better comply with th... #197

Merged
merged 1 commit into from

2 participants

Eric Barr Kyle
Eric Barr
Owner

...e latest vc11 changes.

Added comments for what each part of the capture group does.

Eric Barr apathyboy Modified the regular expression for name checks to better comply with…
… the latest vc11 changes.

Added comments for what each part of the capture group does.
cb8a233
Kyle Kronos11 merged commit 9edb978 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 1, 2012
  1. Eric Barr

    Modified the regular expression for name checks to better comply with…

    apathyboy authored
    … the latest vc11 changes.
    
    Added comments for what each part of the capture group does.
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 3 deletions.
  1. +9 −3 src/swganh/character/character_service.cc
12 src/swganh/character/character_service.cc
View
@@ -231,7 +231,13 @@ std::tuple<uint64_t, std::string> CharacterService::CreateCharacter(const Client
// Only letters, and the ' and - characters are allowed. Only 3 instances
// of the ' and - characters may be in the entire name, which must be between
// 3 and 16 characters long.
- const wregex p(L"(?!['-])(?!.*['-].*['-].*['-].*['-])([a-zA-Z][a-z'-]{3,16}?)(?: ([a-zA-Z][a-z'-]{3,16}?))?");
+ const wregex p(
+ L"(?!['-])" // confirm the first character is not ' or -
+ L"(?!(.*['-]){4,})" // Confirm that no more than 3 instances of ' or - appear
+ L"([a-zA-Z][a-z'-]{2,15})" // Firstname capture group: 3-16 chars must be a-zA-Z or ' or -
+ L"(\\s([a-zA-Z][a-z'-]{2,15}))?" // Optional sirname group, same restrictions as sirname
+ );
+
wsmatch m;
if (! regex_match(character_info.character_name, m, p)) {
@@ -239,8 +245,8 @@ std::tuple<uint64_t, std::string> CharacterService::CreateCharacter(const Client
return make_tuple(0,"name_declined_syntax");
}
- std::wstring first_name = m[1].str();
- std::wstring last_name = m[2].str();
+ std::wstring first_name = m[2].str();
+ std::wstring last_name = m[4].str();
std::wstring custom_name = first_name;
if (!last_name.empty())
Something went wrong with that request. Please try again.