Refactor parse plain serial #4715
This commit is contained in:
parent
0429986470
commit
978c97cbc0
|
@ -118,18 +118,12 @@ void
|
|||
SubscriptionManager::parsePlainSerial(const String& plainText, SubscriptionKey& key)
|
||||
{
|
||||
String serial;
|
||||
bool parity = false;
|
||||
String parityStart = plainText.substr(0, 1);
|
||||
String parityEnd = plainText.substr(plainText.length() - 1, 1);
|
||||
|
||||
// check for parity chars { and }, record parity result, then remove them.
|
||||
if (parityStart == "{" && parityEnd == "}") {
|
||||
parity = true;
|
||||
serial = plainText.substr(1, plainText.length() - 2);
|
||||
}
|
||||
else {
|
||||
serial = plainText;
|
||||
}
|
||||
|
||||
// tokenize serialised subscription.
|
||||
std::vector<String> parts;
|
||||
|
@ -147,8 +141,7 @@ SubscriptionManager::parsePlainSerial(const String& plainText, SubscriptionKey&
|
|||
}
|
||||
|
||||
// e.g.: {v1;trial;Bob;1;1398297600;1398384000}
|
||||
if (parity
|
||||
&& (parts.size() == 6)
|
||||
if ((parts.size() == 6)
|
||||
&& (parts.at(0).find("v1") != String::npos)) {
|
||||
key.m_type = parts.at(1);
|
||||
key.m_name = parts.at(2);
|
||||
|
@ -176,6 +169,7 @@ SubscriptionManager::parsePlainSerial(const String& plainText, SubscriptionKey&
|
|||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
throw XSubscription(synergy::string::sprintf("Serial is invalid."));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue