mirror of https://notabug.org/acetone/ircabot.git
Config reading fix
parent
0f2aad299b
commit
ddc074c0e4
|
@ -44,10 +44,10 @@ void ApplicationData::createConfigExample(const QString &pathToConfig)
|
|||
"# triggers splitting by '<!>'\n"
|
||||
"triggers = request = hi ::: answer = hello <!> request=developer:::answer=acetone\n\n"
|
||||
"# Optional parameters if global is defined:\n"
|
||||
"nick = unique_nickname_for_this_server\n"
|
||||
"user = unique_ident_for_this_server\n"
|
||||
"real_name = unique_real_name_for_this_server\n"
|
||||
"password = password_for_this_user\n"
|
||||
"#nick = unique_nickname_for_this_server\n"
|
||||
"#user = unique_ident_for_this_server\n"
|
||||
"#real_name = unique_real_name_for_this_server\n"
|
||||
"#password = password_for_this_user\n"
|
||||
};
|
||||
|
||||
file.write(configExample.toUtf8());
|
||||
|
@ -124,7 +124,7 @@ void ApplicationData::readConfig()
|
|||
if (globalBegin == -1) {
|
||||
throw std::runtime_error("ApplicationData::readConfig(): Wrong config. [GLOBAL] section not exist!");
|
||||
}
|
||||
int globalEnd = conffile.indexOf('[', globalBegin+1);
|
||||
int globalEnd = conffile.indexOf(QRegularExpression("\\[[^:]*\\]"), globalBegin+1); //IPv6 addresses safe
|
||||
if (globalEnd != -1) {
|
||||
// Удаление последующей [секции]
|
||||
globalSection.remove(globalEnd, conffile.size()-globalEnd);
|
||||
|
@ -193,7 +193,7 @@ void ApplicationData::readConfig()
|
|||
while (conffile.contains(QRegularExpression("\\[[^\\n]*\\]"))) {
|
||||
QString currentSection {conffile};
|
||||
int begin = conffile.indexOf(QRegularExpression("\\[[^\\n]*\\]"));
|
||||
int end = conffile.indexOf('[', begin+1);
|
||||
int end = conffile.indexOf(QRegularExpression("\\[[^:]*\\]"), begin+1);
|
||||
if (end != -1) {
|
||||
currentSection.remove(end, currentSection.size() - end);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue